diff options
Diffstat (limited to 't')
-rw-r--r-- | t/11-Shared-Logging.t | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/t/11-Shared-Logging.t b/t/11-Shared-Logging.t index db27d5b2..3840eeea 100644 --- a/t/11-Shared-Logging.t +++ b/t/11-Shared-Logging.t @@ -1,6 +1,7 @@ use 5.006; use strict; use warnings FATAL => 'all'; +use Sys::Syslog qw(:macros); use Test::More; use Data::Dumper; @@ -18,24 +19,37 @@ ok ( $obj->E("test err %d", 3), 'err_logging'); ok ( $obj->D("test debug %d", 4), 'debug_logging'); $obj = undef; -my $o = ManaTools::Shared::JournalCtl->new(this_boot=>1,); -$o->identifier('test_logging'); +# let's test an identified logger ok ( $obj = ManaTools::Shared::Logging->new(ident => 'test_logging'), 'new_test_logging'); ok ( $obj->D("test debug %d", 5), 'debug_logging as test_logging'); ok ( $obj->I("test info %d", 6), 'info_logging as test_logging'); ok ( $obj->W("test warning %d", 7), 'warning_logging as test_logging'); ok ( $obj->E("test err %d", 8), 'err_logging as test_logging'); -#let's wait journalctl to be updated + +# disable debug level +ok ( $obj->setmask( LOG_UPTO(LOG_INFO) ), 'setmask up to info' ); +ok ( $obj->I("test info (debug disabled) %d", 9), 'info with debug disabled as test_logging'); +isnt ( $obj->D("test debug (debug disabled) %d", 10), 1, 'debug disabled as test_logging'); + +# let's check logged string int journalctl +my $o = ManaTools::Shared::JournalCtl->new(this_boot=>1,); +$o->identifier('test_logging'); +# let's wait journalctl to be updated sleep 1; my $c = $o->getLog(); my $str = $c->[-1]; -ok($str =~ "test err 8", 'test err found'); +isnt($str =~ /test debug \(debug disabled\) 10/, 1, 'debug disabled'); +ok($str =~ /test info \(debug disabled\) 9/, 'info with debug disabled'); + $str = $c->[-2]; -ok($str =~ "test warning 7", 'test warning found'); +ok($str =~ /test err 8/, 'test err found'); $str = $c->[-3]; -ok($str =~ "test info 6", 'test info found'); +ok($str =~ /test warning 7/, 'test warning found'); $str = $c->[-4]; -ok($str =~ "test debug 5", 'test debug found'); +ok($str =~ /test info 6/, 'test info found'); +$str = $c->[-5]; +ok($str =~ /test debug 5/, 'test debug found'); + done_testing; |