4 use Log::Contextual qw{:log with_logger set_logger};
5 use Log::Contextual::SimpleLogger;
6 use Test::More qw(no_plan);
10 my $var_logger1 = Log::Contextual::SimpleLogger->new({
11 levels => [qw(trace debug info warn error fatal)],
12 coderef => sub { $var1 = shift },
16 $var_logger2 = Log::Contextual::SimpleLogger->new({
17 levels => [qw(trace debug info warn error fatal)],
18 coderef => sub { $var2 = shift },
24 $var_logger3 = Log::Contextual::SimpleLogger->new({
25 levels => [qw(trace debug info warn error fatal)],
26 coderef => sub { $var3 = shift },
32 use Log::Contextual qw{:dlog :log with_logger set_logger}, -default_logger => $var_logger3;
38 Dlog_debug { "bar: $_" } 'frew';
44 use Log::Contextual qw{:log with_logger set_logger}, -default_logger => $var_logger2;
53 is($var2, "[debug] foo\n", 'default_logger works for one package');
54 is($var3, "[debug] bar\n", 'default_logger works for both packages');
56 is($var3, qq([debug] bar: "frew"\n), 'default_logger works for one package');
58 set_logger($var_logger1);
61 is($var2, q(), '... but set_logger wins');
62 is($var1, "[debug] foo\n", '... and gets the value');