From: Matthew K. <mk...@ne...> - 2003-07-03 22:09:09
|
>There's currently no 'official' way to do that, but Perl certainly >lets you take a peek without hacking Log::Log4perl: > %Log::Log4perl::Logger::APPENDER_BY_NAME You know, I must have had about six tries at doing that and couldn't get the package qualification right (although it seems pretty obvious now). Thanks very much. > For better encapsulation, we should probably provide > an appenders() method returning a ref to the hash, as in the patch below. > Thoughts? Definitely agree, in fact in one of the hacks that I did I created a get_appender_by_name method sub get_appender_by_name { my ($self, $appender_name) = @_ ; return $APPENDER_BY_NAME{$appender_name} ; } I don't know whether it's better from an OO interface standpoint to have access to the internal hash, or to be able to return individual entries (probably doesn't really matter, I'm certainly no OO bigot). Either way, I think it's a good (and easy) modification to have, especially where, as I said, the actual configuration happens outside your program. > > -- Mike > > Mike Schilli > log...@pe... > http://perlmeister.com > http://log4perl.sourceforge.net > > Index: Logger.pm > =================================================================== > RCS file: /cvsroot/log4perl/Log-Log4perl/lib/Log/Log4perl/Logger.pm,v > retrieving revision 1.49 > diff -a -u -r1.49 Logger.pm > --- Logger.pm 10 Jun 2003 07:02:41 -0000 1.49 > +++ Logger.pm 3 Jul 2003 18:49:22 -0000 > @@ -456,6 +456,12 @@ > } > > ################################################## > +sub appenders { > +################################################## > + return \%APPENDER_BY_NAME; > +} > + > +################################################## > sub has_appenders { > ################################################## > my($self) = @_; > |