Re: Getting MooseX::Traits and Log::Log4perl to play nice
[email protected] (Dave Rolsky)
| Newsgroups | perl.moose |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 19 Jan 2009, Dan Harbin wrote:
> Log::Log4perl encourages you to maintain a hierarchy of loggers that matches
> your class hierarchy. I was achieving this by doing:
> Log::Log4perl->get_logger(shift->meta->name). This works great except with
> anonymous classes since I can't turn on logging in a particular class unless
> I know what the class name will be ahead of time.
>
> Has anyone solved this problem?
sub name_for_logger
{
my $self = shift;
my $name = $self->meta()->name();
return $name unless $name =~ /SERIAL/;
return ( $self->meta()->superclasses() )[0];
}
I think that's what you want.
-dave
/*============================================================
http://VegGuide.org http://blog.urth.org
Your guide to all that's veg House Absolute(ly Pointless)
============================================================*/