Checking in changes prior to tagging of version 0.1.1.
Changelog diff is: diff --git a/Changes b/Changes index b732829..0a53712 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,9 @@ Revision history for Perl extension Log-Mini {{$NEXT}} +0.1.1 2019-03-19T20:44:04Z + - Error in the constructor was fixed. 0.1.0 removed from CPAN. + 0.1.0 2019-03-19T12:08:23Z - Supports formatted with sprintf messages - log method was added
This commit is contained in:
parent
f5c0a42887
commit
0bd73580aa
8 changed files with 42 additions and 9 deletions
3
Changes
3
Changes
|
@ -2,6 +2,9 @@ Revision history for Perl extension Log-Mini
|
|||
|
||||
{{$NEXT}}
|
||||
|
||||
0.1.1 2019-03-19T20:44:04Z
|
||||
- Error in the constructor was fixed. 0.1.0 removed from CPAN.
|
||||
|
||||
0.1.0 2019-03-19T12:08:23Z
|
||||
- Supports formatted with sprintf messages
|
||||
- log method was added
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
"web" : "https://github.com/alpha6/Log-Mini"
|
||||
}
|
||||
},
|
||||
"version" : "0.1.0",
|
||||
"version" : "0.1.1",
|
||||
"x_serialization_backend" : "JSON::PP version 2.93",
|
||||
"x_static_install" : 1
|
||||
}
|
||||
|
|
|
@ -3,19 +3,23 @@ package Log::Mini;
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
our $VERSION = "0.1.0";
|
||||
our $VERSION = "0.1.1";
|
||||
|
||||
use Log::Mini::LoggerFILE;
|
||||
use Log::Mini::LoggerSTDERR;
|
||||
|
||||
use Data::Dumper;
|
||||
use feature qw/say/;
|
||||
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
shift;
|
||||
my ( $type, @args ) = @_;
|
||||
|
||||
$type = 'stderr' unless defined $type;
|
||||
|
||||
if ( $type eq 'file' ) {
|
||||
return Log::Mini::LoggerFILE->new(@args);
|
||||
return Log::Mini::LoggerFILE->new(@_);
|
||||
}
|
||||
else {
|
||||
return Log::Mini::LoggerSTDERR->new(@args);
|
||||
|
|
|
@ -7,6 +7,8 @@ use Carp qw(croak);
|
|||
use List::Util qw(first);
|
||||
use Time::Moment;
|
||||
|
||||
use Data::Dumper;
|
||||
use feature qw/say/;
|
||||
|
||||
my $LEVELS = {
|
||||
error => 1,
|
||||
|
@ -17,13 +19,14 @@ my $LEVELS = {
|
|||
};
|
||||
|
||||
sub new {
|
||||
|
||||
# say STDERR Dumper(\@_);
|
||||
my $class = shift;
|
||||
my (%params) = @_;
|
||||
|
||||
my $self = {};
|
||||
bless $self, $class;
|
||||
|
||||
$self->{'file'} = $params{'file'};
|
||||
$self->{'level'} = $params{'level'} || 'error';
|
||||
|
||||
return $self;
|
||||
|
|
|
@ -12,7 +12,6 @@ sub new {
|
|||
my (%params) = @_;
|
||||
|
||||
$self->{file} = $params{file};
|
||||
$self->{'level'} = $params{'level'} || 'error';
|
||||
|
||||
open my $fh, '>>', $params{file} or die $!;
|
||||
if (defined $params{'synced'}) {
|
||||
|
|
|
@ -4,6 +4,7 @@ use warnings;
|
|||
|
||||
use Test::More;
|
||||
use Test::Fatal;
|
||||
use File::Temp;
|
||||
use Log::Mini;
|
||||
|
||||
subtest 'creates stderr logger' => sub {
|
||||
|
@ -13,7 +14,8 @@ subtest 'creates stderr logger' => sub {
|
|||
};
|
||||
|
||||
subtest 'creates file logger' => sub {
|
||||
my $logger = Log::Mini->new('file');
|
||||
my $file = File::Temp->new;
|
||||
my $logger = Log::Mini->new('file' => $file->filename);
|
||||
|
||||
isa_ok $logger, 'Log::Mini::LoggerFILE';
|
||||
};
|
||||
|
|
|
@ -44,7 +44,7 @@ subtest 'prints to stderr with \n' => sub {
|
|||
for my $level (qw/error warn debug/) {
|
||||
|
||||
my $file = File::Temp->new;
|
||||
my $log = _build_logger(file => $file);
|
||||
my $log = _build_logger(file => $file->filename);
|
||||
|
||||
$log->$level('message');
|
||||
|
||||
|
@ -59,7 +59,7 @@ subtest 'prints to stderr with \n' => sub {
|
|||
subtest 'prints sprintf formatted line' => sub {
|
||||
for my $level (qw/error warn debug/) {
|
||||
my $file = File::Temp->new;
|
||||
my $log = _build_logger(file => $file);
|
||||
my $log = _build_logger(file => $file->filename);
|
||||
|
||||
$log->$level('message %s', 'formatted');
|
||||
|
||||
|
|
22
t/05_Integration.t
Normal file
22
t/05_Integration.t
Normal file
|
@ -0,0 +1,22 @@
|
|||
use lib 'lib';
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Test::More;
|
||||
use Test::Fatal;
|
||||
use File::Temp;
|
||||
use Log::Mini;
|
||||
|
||||
|
||||
|
||||
subtest 'creates correct object LoggerFILE' => sub {
|
||||
my $file = File::Temp->new;
|
||||
isa_ok(Log::Mini->new( file => $file->filename), 'Log::Mini::LoggerFILE');
|
||||
};
|
||||
|
||||
subtest 'creates correct object LoggerSTDERR' => sub {
|
||||
isa_ok(Log::Mini->new('stderr', level => 'debug'), 'Log::Mini::LoggerSTDERR');
|
||||
isa_ok(Log::Mini::LoggerSTDERR->new(level => 'debug'), 'Log::Mini::LoggerSTDERR');
|
||||
};
|
||||
|
||||
done_testing;
|
Loading…
Reference in a new issue