Thanks, Dave. That's just what I needed.
On Mon, Jan 19, 2009 at 1:19 PM, Dave Rolsky <[email protected]> wrote:
> On Mon, 19 Jan 2009, Dave Rolsky wrote:
>
> 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/;
>>
>
> Better ...
>
> return $self->meta()->name() if $self->meta()->is_anon();
>
>
>
> -dave
>
> /*============================================================
> http://VegGuide.org http://blog.urth.org
> Your guide to all that's veg House Absolute(ly Pointless)
> ============================================================*/
>