On Wed Jan 23 23:02:14 2013, MSCHILLI wrote:
Show quoted text> On Wed Jan 23 20:07:32 2013, JJSCHUTZ wrote:
> > Currently, @levels in init() is hard-coded.
> > It would be nice to make this configurable so that custom log levels
> can be easily added.
> > For example, we add 'critical' and 'emergency' levels, and to do that
> as
> > it stands we need to cut and paste the init() code and repeat with the
> > extra levels.
>
> Interesting, so Log::Log4perl::Logger::create_custom_level() as
> described in
>
>
http://search.cpan.org/dist/Log-
> Log4perl/lib/Log/Log4perl.pm#Custom_Log_Levels
>
> doesn't work for you? -- Mike
No, it certainly does work, and very nicely thankyou.
The problem is that Log::Log4perl::Catalyst creates a wrapper around Log::Log4perl
methods, as is done in Log::Log4perl::Catalyst::init. It only creates the wrappers for
the standard methods qw/debug info warn error fatal/. I do create_custom_level()
elsewhere but then have to duplicate the volumes of code that create the wrappers as
well.
Thus instead of (in init())
my @levels = qw[ debug info warn error fatal ];
perhaps there could be a class variable that could be overridden by a subclass, so
something like this could be done:
package My::Catalyst::Logger;
use base 'Log::Log4perl::Catalyst';
__PACKAGE__->levels([ qw[ debug info warn error fatal critical emergency] ]);
Hope that's clarified the issue.