[Catalyst] Redirecting the log

Matt S Trout dbix-class at trout.me.uk
Fri Jan 13 19:08:38 CET 2006


On Thu, Jan 12, 2006 at 11:43:53AM -0800, Ovid wrote:
> Hi all,
> 
> I know that Catalyst::Log has instructions for using a different
> logger, but rather than use a different one, I'd rather just be able to
> alter one tiny piece of behavior in the current one.  Right now, the
> "_flush" method is defined as follows:
> 
>   sub _flush {
>       my $self = shift;
>       if ( $self->abort || !$self->body ) {
>           $self->abort(undef);
>       }
>       else {
>           print( STDERR $self->body );
>       }
>       $self->body(undef);
>   }
> 
> That "print STDERR" is causing me some difficulties.  There are other
> things I would like to do with that.  What I would much rather do is
> this:
> 
>   sub _flush {
>       my $self = shift;
>       if ( $self->abort || !$self->body ) {
>           $self->abort(undef);
>       }
>       else {
>           $self->send_to_log( $self->body );
>       }
>       $self->body(undef);
>   }
> 
>   sub send_to_log {
>       my $self = shift;
>       print STDERR @_;
>   }
> 
> Then, to alter that behavior, I just subclass Catalyst::Log and alter
> that one method.  Before I change the code and submit a patch, is there
> anything I'm missing or is there a better way of handling this?

Given nobody's suggested a better idea, I'd say do up a patch + test case.
 
> Also, I can't recall if patches are preferred inline or as attachments.

Either should be fine.

-- 
     Matt S Trout       Offering custom development, consultancy and support
  Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Catalyst mailing list