Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Hi there fellow monasterians ,

I appear to have encountered an unexpected problem whilst trying to extend Log::Log4perl by way of subclassing it as in (simple form) ...

#! /usr/bin/env perl package L4P::Subclass; use Log::Log4perl qw/:no_extra_logdie_message :levels/; our @ISA = qw/Log::Log4perl/; Log::Log4perl->wrapper_register( __PACKAGE__ ); Log::Log4perl->easy_init( { name => 'LOG', file => "STDOUT", layout => '[%d - %r] %p (%c) %M:%L %m%n', level => $TRACE, } ) or die 'easy_init() failed - '; sub new { my $pkg = shift; my $log = bless Log::Log4perl->get_logger(caller()), __PACKAGE__; warn $log->get_logger(caller())->category(); return $log; } sub trace_start { my $self = shift; $self->debug("Starting with args: " . join ', ', @_); } #our $AUTOLOAD; sub AUTOLOAD { my $self = shift; (my $method = $AUTOLOAD) =~ s/.*://; Log::Log4perl->get_logger(caller())->$method(@_); } package main; my $log = L4P::Subclass->new(); $log->trace_start("Please don't let it be L4P::Subclass");

However, when the script is run, the output is

L4P.Subclass at work/repos/Git/tools/lib/IBM-PTC-Core/LogTest.pl line +22. [2013/02/20 14:22:48 - 1] DEBUG (L4P.Subclass) main:::44 Starting with + args: Please don't let it be L4P::Subclass
- the, not necessarily clear, problem is that although the package name and line number are correct (as in main::44), the category of the logged message is always L4P.SubClass c/w the expected value of main.

Question is, have I done something wrong in my code or is there actually something wrong ?

As always, any help &/or hints will be gratefully received.

TIA & rgds ,

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

In reply to Subclassing L4P appears to generate fixed category log messages by Bloodnok

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (13)
    As of 2014-09-01 13:52 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite cookbook is:










      Results (13 votes), past polls