[Catalyst] (no subject)

Christian Lackas christian at lackas.net
Fri Jan 9 14:00:28 GMT 2009


Hi Everybody,

I wonder if there is any simple way to always include runtime
information into Catalyst's logging.
In particular, I use Catalyst::Log::Log4perl to log activity of my
application, showing the user that triggered an event, such as:

    $c->log->info("[".$c->user->username."] "."actual message");

and would like to avoid having to manually include the username in every
message.
Is it somehow possible to have Catalyst or Log4perl include the 

    "[".$c->user->username."]"

part automatically?

I already found (which I set in MyApp.pm)

    Log::Log4perl::Layout::PatternLayout::add_global_cspec('U',
        sub { return "xxx"; }
    );

which adds a '%U' to the output pattern. However, I see no way to give
the closure the instance of the currently running MyApp (so I can assess
the user() method).

How do you handle situations like this?

Best regards,
 Christian




More information about the Catalyst mailing list