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' => sub{
  my $orig = shift;
  my $self = shift;
  return $self->$orig if @_;
  my $log = $self->$orig;
  $log->action($self->action) if blessed $self && $self->action;
  return $log;
};

package MyApp::Catalyst::Log;
use Moose;
extends 'Catalyst::Log';

has 'action' => ( isa => 'Object', is => 'rw' );

around 'debug' => sub{
  my $orig = shift;
  my $self = shift;
  $_[0] = $self->action.": ".$_[0];
  return $self->$orig(@_);
};

1;

cheers,

J

On Tue, Jan 19, 2010 at 6:22 AM, Kiffin Gish <kiffin.g...@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.g...@planet.nl>
> Gouda, The Netherlands
>
>
>
> _______________________________________________
> 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/
>



-- 
Jason Galea
Web Developer

Ph 07 40556926
Mob 04 12345 534
www.eightdegrees.com.au
_______________________________________________
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/

Reply via email to