Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Log-Contextual CPAN distribution.

Report information
The Basics
Id: 72986
Status: rejected
Priority: 0/
Queue: Log-Contextual

People
Owner: Nobody in particular
Requestors: ether [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.004001
Fixed in: (no value)



Subject: Using a parent logging class generates a warning
I'm having difficulty creating a parent logging class based on the examples provided in the docs (or actually getting *any* self-encapsulated code example to work): { package MyLogger; use strict; use warnings; use parent 'Log::Contextual'; use Log::Log4perl ':easy'; Log::Log4perl->easy_init($DEBUG); sub arg_logger { $_[1] || Log::Log4perl->get_logger } } { package Foo; use strict; use warnings; use MyLogger ':log'; sub foo { log_warn { "here is a log warning in Foo!" }; } } { package Bar; use strict; use warnings; use MyLogger ':log'; sub bar { log_warn { "here is a log warning in Bar!" }; } } Foo::foo(); Bar::bar(); When run, this outputs: set_logger (or -logger) called more than once! This is a bad idea! at /usr/lib/perl5/site_perl/5.8.8/Log/Contextual.pm line 136. 2011/12/06 00:51:45 here is a log warning in Foo! 2011/12/06 00:51:45 here is a log warning in Bar! set_logger is being called by Log/Contextual.pm line 81, in after_import, which seems to be magic set up by Exporter::Declare. Is it not possible to call a Log::Contextual parent logging class twice in the same application? How then can multiple packages share common logging code, as is the intent? (In the same vein, I think there is a documentation error, in the "eventually you will get tired of writing the following..." code snippet - "-logger => " should probably be "-package_logger => " I think?) I've searched your blog, http://blog.afoolishmanifesto.com, for examples that work but haven't found any success there yet either... :/
not a bug (solved in IRC)