From: Arthur Axel 'fREW' Schmidt Date: Sat, 21 Jul 2012 03:34:16 +0000 (-0500) Subject: much better example for defaulting loggers X-Git-Tag: v0.004200~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2b40dee526bae6739447f2c219f694e5ce771d66;p=p5sagit%2FLog-Contextual.git much better example for defaulting loggers --- diff --git a/lib/Log/Contextual.pm b/lib/Log/Contextual.pm index 5b43622..1cfa643 100644 --- a/lib/Log/Contextual.pm +++ b/lib/Log/Contextual.pm @@ -332,21 +332,24 @@ own C subclass as follows: use Log::Log4perl ':easy'; Log::Log4perl->easy_init($DEBUG) - sub arg_logger { $_[1] || Log::Log4perl->get_logger } + sub arg_default_logger { $_[1] || Log::Log4perl->get_logger } sub arg_levels { [qw(debug trace warn info error fatal custom_level)] } - # and *maybe* even these: + # or maybe instead of default_logger sub arg_package_logger { $_[1] } - sub arg_default_logger { $_[1] } -Note the C<< $_[1] || >> in C. All of these methods are passed the -values passed in from the arguments to the subclass, so you can either throw -them away, honor them, die on usage, or whatever. To be clear, if you define -your subclass, and someone uses it as follows: + # and almost definitely not this, which is only here for completeness + sub arg_logger { $_[1] } - use MyApp::Log::Contextual -logger => $foo, -levels => [qw(bar baz biff)]; +Note the C<< $_[1] || >> in C. All of these methods are +passed the values passed in from the arguments to the subclass, so you can +either throw them away, honor them, die on usage, or whatever. To be clear, +if you define your subclass, and someone uses it as follows: -Your C method will get C<$foo> and your C + use MyApp::Log::Contextual -default_logger => $foo, + -levels => [qw(bar baz biff)]; + +Your C method will get C<$foo> and your C will get C<[qw(bar baz biff)]>; =head1 FUNCTIONS