From: Adrian I. <adr...@ho...> - 2006-12-29 09:29:26
|
Hi, As far as I can tell it doesn't. I use Log4Perl via a wrapper and have found that my logdies are reported as occurring in my wrapper rather than in the code calling the wrapper. This is despite my setting $Log::Log4perl::caller_depth = 1 in the package defining my wrapper. The first reason I think the problem lies in the Log4Perl code and not my own is that I searched for caller_depth in the Log4Perl code and while there are a number of places it's changed, it only seems to be used in the Log::Log4perl::Layout::PatternLayout::render subroutine which isn't involved in the implementation of logdie. After some further investigation I think the problem is in the Log4Perl::Logger module. In particular the callerline subroutine. I've attached a diff for Logger.pm that fixes the problem which works as follows: i) Keep stepping up the call-stack until you've reached caller_depth steps out of the current file. ii) Don't evaluate the call stack if it's not needed for the message iii) Avoid a uninitialized warning from the 'at $file line $line' in the case where the caller_depth has been set too large. Points (ii) and (iii) don't actually fix the problem at hand but, in my opinion, do improve things slightly . Potentially (iii) could be implemented better (i.e. print a warning about caller_depth being wrong, allowing the thread id to be added to the message even if we've failed with $file etc) but that's up to you :o) Cheers, Adrian NB I'm using 'Log-Log4perl' version 1.05 in ActivePerl 5.8.4.810. I know 1.08 is available but I'm using Windows XP and 1.05 is the latest available via ppm. NNB I had a look at the release notes between 1.05 and 1.08 and couldn't see any mention of something fixing this problem . |