[Catalyst] Problem with $c->log always on

Wade.Stuart at fallon.com Wade.Stuart at fallon.com
Tue Sep 12 22:18:33 CEST 2006







catalyst-bounces at lists.rawmode.org wrote on 09/12/2006 01:24:33 PM:

> Matt S Trout wrote:
> > Nate Wiger wrote:
> >> It looks like $c->log is always on in a given Catalyst plugin. I have
> >> simple, standard code like this:
> >>
> >>     $c->log->debug("some message");
> >>     $c->log->debug(Dumper(\%hash)) if $c->log->is_debug;
> >>
> >> When I dump out the $c->log->is*, all of them return true (actually,
> >> 1/4/16 depending on the level, I assume this is a bitmask byproduct).
> >>
> >> Any ideas? Anyone else seen this? I even double-checked my classes to
> >> make sure they aren't overriding it...
> >
> > Log level config is separate from debug mode.
> >
> > __PACKAGE__->log(Catalyst::Log->new(@levels));
> >
> > or
> >
> > $c->log->debug(...) if $c->debug; # this is what the Cat internals do
>
> Ok, perhaps I'm a bit confused... reading the Catalyst::Log manpage, it
> seems I should just be able to write this:
>
>     $c->log->whatever_level("message");
>
> And it will/won't be shown depending on the runtime level config. Is
> that correct?

that is what mst is saying,  defaulty the log new turns all on,  if you
only want specific levels turned on you need to do the
__PACKAGE__->log(Catalyst::Log->new(@levels)); to set the specific levels
on.  and then $c->log->levelname("blah"); will work as you expect.  If you
don't specify your own @levels on the new you would need to test as in his
second example.

>
> -Nate




More information about the Catalyst mailing list