|
From: Mike S. <m...@pe...> - 2011-01-31 00:15:10
|
On Sun, 30 Jan 2011, David Christensen wrote:
> Putting the 'use' statement before the 'BEGIN' statement makes Perl
> happy, but %c still shows the Helper package, not 'main':
Ugh, that doesn't work in :easy mode, sorry about that.
What you want to do instead is use the long form with get_logger():
package Helper;
use Log::Log4perl qw(get_logger);
Log::Log4perl->wrapper_register(__PACKAGE__);
sub help { get_logger()->debug(__FILE__, "-", __LINE__, ' ', @_) }
package Foo;
sub foo { Helper::help("blah"); }
package main;
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init({layout=>'%c %m %n'});
DEBUG(__FILE__, "-", __LINE__);
Helper::help(__FILE__, "-", __LINE__);
Foo::foo();
-- Mike
Mike Schilli
m...@pe...
|