FAQ
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..");
}


It seems to be sending the log message no matter if ( $c->is_fatal() )



I even start the server with myapp_server.pl -d debug

What am I missing here does catalyst only have debug log level or not
debug log level and not log levels in general?

Search Discussions

  • Andreas Marienborg at Feb 28, 2008 at 11:36 am
    The internal logger is quite "simple" in that it logs with different
    levels, but don't really care much aside from that.

    A very common construction in my programs is:

    $c->log->debug("amg, nevah show this in prod please") if $c->debug

    myapp_server.pl -d only sets $c->debug to true, but the default logger
    doesn't care much.

    A good/better alternative comes with Catalyst::Log::Log4perl, which
    converts $c->log into a Log::Log4perl logger (more or less at least),
    which lets you configure at a nice granularity what gets logged where
    and when.


    - andreas
    On Feb 25, 2008, at 10:25 PM, 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..");
    }


    It seems to be sending the log message no matter if ( $c->is_fatal() )



    I even start the server with myapp_server.pl -d debug

    What am I missing here does catalyst only have debug log level or
    not debug log level and not log levels in general?

    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
  • Matt Lawrence at Mar 4, 2008 at 5:22 pm

    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..");
    }

    Have a look at docs for Catalyst::Log

    Matt
  • Bill Moseley at Mar 4, 2008 at 9:13 pm

    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@hank.org
  • Matt Lawrence at Mar 5, 2008 at 10:59 am

    Bill Moseley wrote:
    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...');
    Quite right, I was imagining the OP was going to do more heavy-duty
    debugging for which the sample code was a test case.
    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).
    You can also use MYAPP_DEBUG to set debugging on an app-by-app basis.

    Matt

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedFeb 25, '08 at 9:25p
activeMar 5, '08 at 10:59a
posts5
users4
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2022 Grokbase