Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Subclassing L4P appears to generate fixed category log messages

by zwon (Abbot)
on Feb 23, 2013 at 13:55 UTC ( #1020303=note: print w/replies, xml ) Need Help??

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:
sub new { return bless {}, shift; }
will do the thing, reblessing Logger object into L4P::Subclass somehow confuses Log4perl and AUTOLOAD invokes itself recursively.

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
    TFT, I take your point about the call to bless() - I came to the same conclusion as yourself and blessed an anon scalar into the Subclass - which appears to correct (or, at least) avoid the confusion to L4P.

    A user level that continues to overstate my experience :-))

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1020303]
[LanX]: Socrates was a Troll
[Your Mother]: It's very, very dangerous... Thinking that a group is intrinsically evil... buries the fact that all humans can be so deep that it starts to become likely they will be.
[Your Mother]: LanX++
[Corion]: (also the "troll for trolls sake" could seen be much like the "punk for punks beer")
[Your Mother]: I'm completely (historically anyway) a troll in real life. It's not fun online, you can't really win. :P
Happy-the-monk orders a Punk IPA.
[Your Mother]: Also, I'm too old to start fights with strangers anymore.
[LanX]: concentrating on omestic violence?
[LanX]: d
[Your Mother]: Open air violence. Or on campus.

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (18)
As of 2018-03-19 13:49 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (240 votes). Check out past polls.