in reply to Subclassing L4P appears to generate fixed category log messages
Your problem starts here:
my $log = bless Log::Log4perl->get_logger(caller()), __PACKAGE__;
You're subclassing Log::Log4perl package, but in constructor you're creating Log::Log4perl::Logger object and reblessing it into L4P::Subclass. I think you should in L4P::Subclass implement your own get_logger method which will return L4P::Subclass::Logger object.
Later in AUTOLOAD you're ignoring this logger object and creating a new one:
but AUTOLOAD is called from your package from trace_start, so category is "L4P.Subclass" and not main. You can replace it with caller(1) or just use get_logger() as Log::Log4perl will automatically skip frames belonging to your module because you've registered it as wrapper. But in order this to work you should also fix the constructor, something as simple as:Log::Log4perl->get_logger(caller())->$method(@_);
will do the thing, reblessing Logger object into L4P::Subclass somehow confuses Log4perl and AUTOLOAD invokes itself recursively.sub new { return bless {}, shift; }
PS: also note, that you can create custom log levels. I can't find documentation, but the code is in Log::Log4perl::Logger
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Subclassing L4P appears to generate fixed category log messages
by Bloodnok (Vicar) on Feb 27, 2013 at 13:14 UTC |