BEGIN { $var_log = VarLogger->new }
use Log::Contextual qw{:dlog}, -logger => $var_log;
-
+{
my @foo = Dlog_trace { "Look ma, data: $_" } qw{frew bar baz};
ok( eq_array(\@foo, [qw{frew bar baz}]), 'Dlog_trace passes data through correctly');
is( $var_log->var, <<'OUT', 'Output for Dlog_trace is correct');
"baz"
]
OUT
+}
+{
my @foo = Dlog_debug { "Look ma, data: $_" } qw{frew bar baz};
ok( eq_array(\@foo, [qw{frew bar baz}]), 'Dlog_debug passes data through correctly');
is( $var_log->var, <<'OUT', 'Output for Dlog_debug is correct');
"baz"
]
OUT
+}
+{
my @foo = Dlog_info { "Look ma, data: $_" } qw{frew bar baz};
ok( eq_array(\@foo, [qw{frew bar baz}]), 'Dlog_info passes data through correctly');
is( $var_log->var, <<'OUT', 'Output for Dlog_info is correct');
"baz"
]
OUT
+}
+{
my @foo = Dlog_warn { "Look ma, data: $_" } qw{frew bar baz};
ok( eq_array(\@foo, [qw{frew bar baz}]), 'Dlog_warn passes data through correctly');
is( $var_log->var, <<'OUT', 'Output for Dlog_warn is correct');
"baz"
]
OUT
+}
+{
my @foo = Dlog_error { "Look ma, data: $_" } qw{frew bar baz};
ok( eq_array(\@foo, [qw{frew bar baz}]), 'Dlog_error passes data through correctly');
is( $var_log->var, <<'OUT', 'Output for Dlog_error is correct');
"baz"
]
OUT
+}
+{
my @foo = Dlog_fatal { "Look ma, data: $_" } qw{frew bar baz};
ok( eq_array(\@foo, [qw{frew bar baz}]), 'Dlog_fatal passes data through correctly');
is( $var_log->var, <<'OUT', 'Output for Dlog_fatal is correct');
"baz"
]
OUT
-
+}
use warnings;
use Log::Contextual::SimpleLogger;
-use Log::Contextual qw{:log} => -logger =>
+use Log::Contextual qw{:log set_logger} => -logger =>
Log::Contextual::SimpleLogger->new({levels => [qw{debug}]});
use Test::More qw(no_plan);
my $l = Log::Contextual::SimpleLogger->new({levels => [qw{debug}]});
+ok(!$l->is_trace, 'is_trace is false on SimpleLogger');
ok($l->is_debug, 'is_debug is true on SimpleLogger');
+ok(!$l->is_info, 'is_info is false on SimpleLogger');
+ok(!$l->is_warn, 'is_warn is false on SimpleLogger');
+ok(!$l->is_error, 'is_error is false on SimpleLogger');
+ok(!$l->is_fatal, 'is_fatal is false on SimpleLogger');
-log_debug { 'set_logger' };
-log_trace { die 'this should live' };
+ok(eval { log_trace { die 'this should live' }; 1}, 'trace does not get called');
+ok(!eval { log_debug { die 'this should die' }; 1}, 'debug gets called');
+ok(eval { log_info { die 'this should live' }; 1}, 'info does not get called');
+ok(eval { log_warn { die 'this should live' }; 1}, 'warn does not get called');
+ok(eval { log_error { die 'this should live' }; 1}, 'error does not get called');
+ok(eval { log_fatal { die 'this should live' }; 1}, 'fatal does not get called');