aroc725 has asked for the wisdom of the Perl Monks concerning the following question:

How can I create a wrapper class for the 'Log::Log4perl' module?

Replies are listed 'Best First'.
Re: creating a wrapper class
by shmem (Chancellor) on Jul 17, 2006 at 14:57 UTC
    package SomeClass; use strict; use Log::Log4perl; # do what I mean die "insert your code here"; 1;

    something like this? what is your wrapper class supposed to provide?

    --shmem

    update: added 'use strict'

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      Thanks for responding. What I'd like to do is inherit from 'Log::Log4perl' and then override the 'error', 'info', etc. methods so I can include some extra information in the logged messages.
        See section on Inheritance in perltoot.

        Like this ...

        package MyClass; use strict; use Log::Log4Perl; # this tells perl to look in Log::Log4Perl for methods @MyClass::ISA = qw(Log::Log4Perl); # now override methods with your own ones. # all else is found looked up in packages in # @MyClass::ISA sub error { ... } sub info { ... } 1;

        ... or use the base pragma.

        --shmem

        _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                      /\_¯/(q    /
        ----------------------------  \__(m.====·.(_("always off the crowd"))."·
        ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

        package MyLog; use base qw(Log::Log4Perl); ....

        /J\