From: Arthur Axel 'fREW' Schmidt Date: Sat, 20 Feb 2010 08:15:42 +0000 (-0600) Subject: add more than just debug for varlogger and change tests to match X-Git-Tag: v0.00100~22 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=73c0f681c7fd2f59bc85566fcca70e5b25ed1acb;p=p5sagit%2FLog-Contextual.git add more than just debug for varlogger and change tests to match --- diff --git a/t/dlog.t b/t/dlog.t index 75e8d20..177d21f 100644 --- a/t/dlog.t +++ b/t/dlog.t @@ -13,14 +13,14 @@ set_logger(sub { $var_log }); 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'); -Look ma, data: "frew" +dLook ma, data: "frew" "bar" "baz" OUT my $bar = DlogS_debug { "Look ma, data: $_" } [qw{frew bar baz}]; ok( eq_array($bar, [qw{frew bar baz}]), 'DlogS_debug passes data through correctly'); is( $var_log->var, <<'OUT', 'Output for DlogS_debug is correct'); -Look ma, data: [ +dLook ma, data: [ "frew", "bar", "baz" diff --git a/t/lib/VarLogger.pm b/t/lib/VarLogger.pm index 0e1de89..d92043a 100644 --- a/t/lib/VarLogger.pm +++ b/t/lib/VarLogger.pm @@ -1,8 +1,24 @@ package VarLogger; sub new { bless { var => undef }, __PACKAGE__ } -sub debug { $_[0]->{var} = $_[1] } sub var { $_[0]->{var} } + +sub debug { $_[0]->{var} = "d$_[1]" } sub is_debug { 1 } +sub trace { $_[0]->{var} = "t$_[1]" } +sub is_trace { 1 } + +sub error { $_[0]->{var} = "e$_[1]" } +sub is_error { 1 } + +sub info { $_[0]->{var} = "i$_[1]" } +sub is_info { 1 } + +sub fatal { $_[0]->{var} = "f$_[1]" } +sub is_fatal { 1 } + +sub warn { $_[0]->{var} = "w$_[1]" } +sub is_warn { 1 } + 1; diff --git a/t/log.t b/t/log.t index db34763..6fc26fe 100644 --- a/t/log.t +++ b/t/log.t @@ -19,14 +19,14 @@ WITHLOGGER: { }; - is( $var_logger1->var, 'nothing!', 'inner scoped logger works' ); - is( $var_logger2->var, 'frew!', 'outer scoped logger works' ); + is( $var_logger1->var, 'dnothing!', 'inner scoped logger works' ); + is( $var_logger2->var, 'dfrew!', 'outer scoped logger works' ); } SETLOGGER: { set_logger(sub { $var_logger3 }); log_debug { 'set_logger' }; - is( $var_logger3->var, 'set_logger', 'set logger works' ); + is( $var_logger3->var, 'dset_logger', 'set logger works' ); } SETWITHLOGGER: { @@ -34,12 +34,12 @@ SETWITHLOGGER: { log_debug { 'nothing again!' } }; - is( $var_logger1->var, 'nothing again!', + is( $var_logger1->var, 'dnothing again!', 'inner scoped logger works after using set_logger' ); log_debug { 'frioux!' }; - is( $var_logger3->var, 'frioux!', + is( $var_logger3->var, 'dfrioux!', q{set_logger's logger comes back after scoped logger} ); }