From: Steven L. <le...@wr...> - 2008-01-25 21:52:26
|
--- lib/Log/Log4perl.pm.orig 2008-01-24 18:20:30.319775285 -0500 +++ lib/Log/Log4perl.pm 2008-01-25 16:51:51.220863874 -0500 @@ -2329,7 +2329,7 @@ =head1 Using Log::Log4perl from wrapper classes -If you don't use C<Log::Log4perl> as described above, +If you don't use C<Log::Log4perl> as described above, but from a wrapper class (like your own Logging class which in turn uses C<Log::Log4perl>), the pattern layout will generate wrong data for %F, %C, %L and the like. @@ -2338,11 +2338,25 @@ one (or more) wrapper classes, C<Log::Log4perl> will indicate where your logger classes called the loggers, not where your application called your wrapper, which is probably what you want in this case. -But don't dispair, there's a solution: Just increase the value + +But don't despair, there's a solution: Just increase the value of C<$Log::Log4perl::caller_depth> (defaults to 0) by one for every wrapper that's in between your application and C<Log::Log4perl>, then C<Log::Log4perl> will compensate for the difference. +Using a local variable avoids problems with anyone who +uses Log4perl directly; using ||= allows people to wrap +YOUR wrappers without accidentally resetting the value +too low. + + sub debug + { + local $Log::Log4perl::caller_depth ||= 1; + + ... + } + + =head1 Access to Internals The following methods are only of use if you want to peek/poke in |