From: Arthur Axel 'fREW' Schmidt Date: Sat, 20 Feb 2010 08:04:40 +0000 (-0600) Subject: allow set_logger to wrap objects X-Git-Tag: v0.00100~25 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8dc5a74784dfa95d2548bf25b6cb6d5d25ed6187;p=p5sagit%2FLog-Contextual.git allow set_logger to wrap objects --- diff --git a/lib/Log/Contextual.pm b/lib/Log/Contextual.pm index d1da84f..4155e6b 100644 --- a/lib/Log/Contextual.pm +++ b/lib/Log/Contextual.pm @@ -55,8 +55,11 @@ sub import { our $Get_Logger; -sub set_logger (&) { - $Get_Logger = $_[0]; +sub set_logger { + my $logger = $_[0]; + $logger = do { my $l = $logger; sub { $l } } + if ref $logger ne 'CODE'; + $Get_Logger = $logger; } sub with_logger {