[Catalyst] Subclass $c->log->debug(...) to prepend "${\$c->action}: ..."

J. Shirley jshirley at gmail.com
Tue Jan 19 03:55:55 GMT 2010

On Mon, Jan 18, 2010 at 12:22 PM, Kiffin Gish <kiffin.gish at planet.nl> wrote:
> I'd like to subclass $c->log->debug(message) so that it prints out:
> ''.$c->action.': '.'message'
> What's the easiest way to do this?

Easiest is to just switch to Catalyst::Log::Log4perl, since it will do
what you want out of the box.

Something like this in your log4perl.conf would work:
log4perl.rootLogger=DEBUG, SCREEN

log4perl.appender.SCREEN = Log::Log4perl::Appender
log4perl.appender.SCREEN.stderr = 1
log4perl.appender.SCREEN.layout = Log::Log4perl::Layout::PatternLayout
log4perl.appender.SCREEN.layout.ConversionPattern = %d %p [%c : %L] %m%n

That will give you a log like:
2010/01/12 13:54:40 DEBUG [Catalyst.View.TT : 1881] Rendering template "foo.tt"


More information about the Catalyst mailing list