On Mon, Nov 16, 2009 at 2:47 PM, Jon <[email protected]> wrote:

> 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
>
>
>
I typically use a pattern similar to what is found in InstancePerContext,
and just do $instance->log( $c->log ) (or, in instantiation on the
build_per_context_instance)

-J
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to