[Catalyst] Best Practices : Logging

Jon jonfdaily at wetxt.com
Mon Nov 16 22:47:44 GMT 2009


Hello,
I'm building a new Catalyst app, and am trying to follow the best
practices.  What do people typically do for logging in their Model
classes?

I would like to have something like,

package App::Model::SomeModel;
use strict;
use warnings;
use parent 'Catalyst::Model::Adaptor';

__PACKAGE__->config(
    class => 'App::Logic::SomeModel',
);


package App::SomeModel;
use Moose;

has 'log' => (is => 'ro', isa => 'Catalyst::Plugin::Log::Handler',
lazy_build => 1);

....

sub _build_log {
   my ($self) = @_;
   $self->log(Catalyst::Plugin::Log::Handler->new());
}


But I don't want to have to manually pass configuration details to it
each time.  There is probably a more standard way to take care of this
that I'm just not aware of.  Can I set it up automatically in my
adaptor class?

Thanks,
- Jon



More information about the Catalyst mailing list