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"
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;
};
- 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: {
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}
);
}