#!C:\Perl64\bin\perl.exe
use strict;
use warnings;
use Log::Message private => 0, config => 'e:\Ziptemp\cf_file';
my $log = Log::Message->new( private => 1,
level => 'log',
config => 'e:\Ziptemp\cf_file',
);
$log->store('this is my first message');
$log->store( message => 'message #2',
tag => 'MY_TAG',
level => 'carp',
extra => ['this is an argument to the handler'],
);
my @last_five_items = $log->retrieve(5);
my @items = $log->retrieve( tag => qr/my_tag/i,
message => qr/\d/,
remove => 1,
);
@items = $log->final( level => qr/carp/, amount => 2 );
my $first_error = $log->first();
# croak with the last error on the stack
$log->final->croak;
# empty the stack
$log->flush();
When I run it I get:
message #2 at C:/Perl64/site/lib/Log/Message.pm line 409. at Wed Apr 11 20:02:59 2018
Can't call method "croak" on an undefined value at logtest.pl line 32.
Also, I have an off-topic question: Why are there two config files that are needed? I set them both to the same file for now but I don't understand why it would need to different configuration files?
Thanks,
Jim