[Catalyst] Subclass $c->log->debug(...) to prepend
"${\$c->action}: ..."
Jason Galea
lists at eightdegrees.com.au
Mon Jan 18 23:52:52 GMT 2010
not as simple as I thought. I'd be interested to know if there's an easier
way..
package MyApp;
use MyApp::Catalyst::Log;
__PACKAGE__->setup;
__PACKAGE__->log( MyApp::Catalyst::Log->new );
around 'log' =3D> sub{
my $orig =3D shift;
my $self =3D shift;
return $self->$orig if @_;
my $log =3D $self->$orig;
$log->action($self->action) if blessed $self && $self->action;
return $log;
};
package MyApp::Catalyst::Log;
use Moose;
extends 'Catalyst::Log';
has 'action' =3D> ( isa =3D> 'Object', is =3D> 'rw' );
around 'debug' =3D> sub{
my $orig =3D shift;
my $self =3D shift;
$_[0] =3D $self->action.": ".$_[0];
return $self->$orig(@_);
};
1;
cheers,
J
On Tue, Jan 19, 2010 at 6:22 AM, 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?
>
> --
> Kiffin Gish <Kiffin.Gish at planet.nl>
> Gouda, The Netherlands
>
>
>
> _______________________________________________
> List: Catalyst at 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/
>
-- =
Jason Galea
Web Developer
Ph 07 40556926
Mob 04 12345 534
www.eightdegrees.com.au
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100119/63798=
004/attachment.htm
More information about the Catalyst
mailing list