From: Arthur Axel 'fREW' Schmidt Date: Sun, 21 Feb 2010 00:15:29 +0000 (-0600) Subject: make log_$level passthrough for sweet, sweet refactor X-Git-Tag: v0.00100~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4d8ea78d013babf233fbd7ad987221c8660763b6;p=p5sagit%2FLog-Contextual.git make log_$level passthrough for sweet, sweet refactor --- diff --git a/lib/Log/Contextual.pm b/lib/Log/Contextual.pm index 9aa4fb2..16f34c5 100644 --- a/lib/Log/Contextual.pm +++ b/lib/Log/Contextual.pm @@ -71,40 +71,52 @@ sub with_logger { $_[1]->(); } -sub log_trace (&) { - my $log = $Get_Logger->(); - $log->trace($_[0]->()) +sub log_trace (&@) { + my $log = $Get_Logger->(); + my $code = shift; + $log->trace($code->(@_)) if $log->is_trace; + @_ } -sub log_debug (&) { - my $log = $Get_Logger->(); - $log->debug($_[0]->()) +sub log_debug (&@) { + my $log = $Get_Logger->(); + my $code = shift; + $log->debug($code->(@_)) if $log->is_debug; + @_ } -sub log_info (&) { - my $log = $Get_Logger->(); - $log->info($_[0]->()) +sub log_info (&@) { + my $log = $Get_Logger->(); + my $code = shift; + $log->info($code->(@_)) if $log->is_info; + @_ } -sub log_warn (&) { - my $log = $Get_Logger->(); - $log->warn($_[0]->()) +sub log_warn (&@) { + my $log = $Get_Logger->(); + my $code = shift; + $log->warn($code->(@_)) if $log->is_warn; + @_ } -sub log_error (&) { - my $log = $Get_Logger->(); - $log->error($_[0]->()) +sub log_error (&@) { + my $log = $Get_Logger->(); + my $code = shift; + $log->error($code->(@_)) if $log->is_error; + @_ } -sub log_fatal (&) { - my $log = $Get_Logger->(); - $log->fatal($_[0]->()) +sub log_fatal (&@) { + my $log = $Get_Logger->(); + my $code = shift; + $log->fatal($code->(@_)) if $log->is_fatal; + @_ }