$Get_Logger = $_[0];
}
-sub with_logger (&&) {
- local $Get_Logger = $_[0];
+sub with_logger {
+ my $logger = $_[0];
+ $logger = do { my $l = $logger; sub { $l } }
+ if ref $logger ne 'CODE';
+ local $Get_Logger = $logger;
$_[1]->();
}
my $var_logger3 = VarLogger->new;
WITHLOGGER: {
- with_logger { $var_logger2 } sub {
+ with_logger sub { $var_logger2 } => sub {
- with_logger { $var_logger1 } sub {
+ with_logger $var_logger1 => sub {
log_debug { 'nothing!' }
};
log_debug { 'frew!' };
}
SETWITHLOGGER: {
- with_logger { $var_logger1 } sub {
+ with_logger $var_logger1 => sub {
log_debug { 'nothing again!' }
};