[Catalyst] (no subject)

onken at houseofdesign.de onken at houseofdesign.de
Fri Jan 9 15:02:02 GMT 2009


On Fri, 9 Jan 2009 15:00:28 +0100, Christian Lackas <christian at lackas.net>
wrote:
> 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?

Hi,

in MyApp.pm:

sub log_info {
  my $c = shift;
  $c->log->info("[".$c->user->username."] ". shift );
}

Now you can use $c->log_info("actual message") anywhere and the username
gets prepended.

moritz



More information about the Catalyst mailing list