From: Jim C. <jc...@di...> - 2003-06-03 16:39:53
|
Gordon Marler wrote: >I've been using Log::Log4perl for several months now, with great success >- great job! > >I've designed my Perl object to contain a reference to a Log::Log4perl >object, and this seems to work for all methods in the object except >DESTROY. Here's an example of what my DESTROY method looks like (the >name of my object and it's package is "BE"): > >sub DESTROY { > my ($self) = @_; > my ($logger) = Log::Log4perl->get_logger("BE"); > $logger->info("Entering DESTROY method for " . __PACKAGE__ . "\n"); >} > > >However, when my script ends, I get the following error message as the >DESTROY method of my object gets called: > > (in cleanup) Can't call method "log" on an undefined value at >(eval 271) line 42 during global destruction. > > > a couple things to consider: change the order of use, so that the END block in question runs before Log::Log4perl is unloaded. is your DESTROY being called 'really late' ? ie as a part of process cleanup rather than a variable going out of scope ? If so, Id look to make it (ie $it->DESTROY) a my var, in a package that is reclaimed early in the process end. FWIW - Im using a logger object from an END block succesfully, in Log::Log4perl::AutoCategorize. I put a beta out just recently :-) You may want to look there. (and send me your perftest/timeit.sh results please) |