From 56215cf0d3a176ff293ddaa65f4099be2ada2cba Mon Sep 17 00:00:00 2001 From: Denis Fedoseev Date: Fri, 17 Mar 2023 21:53:33 +0300 Subject: [PATCH] small fixes --- lib/Log/Mini/Logger/Base.pm | 6 +++--- t/03_LoggerFILE.t | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/Log/Mini/Logger/Base.pm b/lib/Log/Mini/Logger/Base.pm index 5e69530..94fc96c 100644 --- a/lib/Log/Mini/Logger/Base.pm +++ b/lib/Log/Mini/Logger/Base.pm @@ -13,7 +13,7 @@ my $LEVELS = { warn => 2, info => 3, debug => 4, - trace => 5 + trace => 5, }; sub new @@ -39,7 +39,7 @@ sub set_level $self->{'level'} = $new_level; - return; + return 1; } sub level @@ -71,7 +71,7 @@ sub _log $self->_print($text); - return; + return 1; } sub _print { croak 'Not implemented!' } diff --git a/t/03_LoggerFILE.t b/t/03_LoggerFILE.t index 142ab48..610d0dd 100644 --- a/t/03_LoggerFILE.t +++ b/t/03_LoggerFILE.t @@ -14,9 +14,9 @@ subtest 'creates correct object' => sub { subtest 'prints to file' => sub { - for my $level (qw/error warn debug/) { + for my $level (qw/error warn info debug trace/) { my $file = File::Temp->new; - my $log = _build_logger(file => $file->filename); + my $log = _build_logger(file => $file->filename, level => $level); $log->$level('message'); undef $log; @@ -31,7 +31,8 @@ subtest 'prints to file synced' => sub { my $file = File::Temp->new; my $log = _build_logger(file => $file->filename, synced => 1); - for my $level (qw/error warn debug/) { + for my $level (qw/error warn info debug trace /) { + $log->set_level($level); $log->$level('message'); my $content = _slurp($file); @@ -41,10 +42,9 @@ subtest 'prints to file synced' => sub { }; subtest 'prints to stderr with \n' => sub { - for my $level (qw/error warn debug/) { - + for my $level (qw/error warn info debug trace/) { my $file = File::Temp->new; - my $log = _build_logger(file => $file->filename); + my $log = _build_logger(file => $file->filename, level => $level); $log->$level('message'); @@ -57,9 +57,9 @@ subtest 'prints to stderr with \n' => sub { }; subtest 'prints sprintf formatted line' => sub { - for my $level (qw/error warn debug/) { + for my $level (qw/error warn info debug trace/) { my $file = File::Temp->new; - my $log = _build_logger(file => $file->filename); + my $log = _build_logger(file => $file->filename, level => $level); $log->$level('message %s', 'formatted'); @@ -80,7 +80,7 @@ sub _slurp { sub _build_logger { my $logger = Log::Mini::Logger::FILE->new(@_); - $logger->set_level('debug'); + return $logger; }