in reply to Re: creating a wrapper class
in thread creating a wrapper class

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.

Replies are listed 'Best First'.
Re^3: creating a wrapper class
by shmem (Chancellor) on Jul 17, 2006 at 15:19 UTC
    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}
Re^3: creating a wrapper class
by gellyfish (Monsignor) on Jul 17, 2006 at 15:12 UTC

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

    /J\

      I'm getting this error message in the Netscape Web server 'errors' log file:

      ...mid_yr_rpt_survey.cgi did not produce a valid header (name without value: got line " (perhaps you need to 'use' the module which defines that package first.)")

      despite having this in the 'HinLog.pm' file:

      package mid_yr_rpt_survey::HinLog;

      use Log::Log4perl qw(get_logger); # don't need this, right?
      use base qw(Log::Log4Perl);

      and this in the 'DBI.pm' module that's trying to use 'HinLog':

      package mid_yr_rpt_survey::DBI; ...
      use mid_yr_rpt_survey::HinLog;
        Don't use Log::Log4perl qw(get_logger); if you use base.

        If you didn't read perltoot and/or base, please do so now :-)

        --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}