[Catalyst] debug mode or debug levels?

Bill Moseley moseley at hank.org
Tue Mar 4 21:13:43 GMT 2008


On Tue, Mar 04, 2008 at 05:22:38PM +0000, Matt Lawrence wrote:
> Tyler Bird wrote:
> >hi I want to only show certain log messages to my console based on the 
> >log level 'debug'
> >I believe catalyst supports log levels, but this doesn't seem to be 
> >working
> >
> >
> >if ( $c->is_debug() )
> >{
> >   $c->log("log message here..");
> >}
> >
> >
> I believe that's spelt:
> 
> if ($c->log->is_debug) {
>    $c->log->debug("log message here..");
> }

Isn't that the same thing as simply:

    $c->log->debug('log message here...');


There's also:

    $c->log->debug('message') if $c->debug;

which, IIRC, is set true if CATALYST_DEBUG is true (or, of course, if
you create a sub debug {1} in your app).

In other words, it's possible to have $c->debug be different from
$c->log->is_debug.  That's helpful as you can have $c->log->debug
messages display but not have all the catalyst-generated debug
messages display because they often written, for example, as:

    $c->log->debug(qq/"$method" request for "$path" from "$address"/)
      if $c->debug;

Before calling setup I often do something like:

    $self->log( Catalyst::Log->new( @log_levels ) );

Where @log_levels can be set via an environment variable.  But that
will break the ability to "use Catalyst '-Debug'" or -LOG=warn.


-- 
Bill Moseley
moseley at hank.org




More information about the Catalyst mailing list