|
From: Gordon M. <gm...@gm...> - 2003-06-03 15:24:54
|
I see what you're getting at - unfortunately, the change to using:
my ($logger) = $self->{_logger};
still fails, as $self->{_logger} is "undef"! As the Data::Dumper output
I included indicates, the Log4perl reference in $self->{_logger} has
been garbage collected by Perl before my object's DESTROY method ever
gets called.
On Tue, 2003-06-03 at 11:18, Kevin Goess wrote:
> > 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.
>
> > Since I'm keeping a reference to the Log::Log4perl object inside my
> > object,
>
> If that's what you're doing, then use the reference instead of asking
> the in-the-process-of-being-garbage-collected log4perl structs for one.
> Try it like this:
>
> sub DESTROY {
> my ($self) = @_;
> my ($logger) = $self->{_logger}; #using exising reference
> $logger->info("Entering DESTROY method for " . __PACKAGE__ . "\n");
> }
>
>
--
Gordon Marler <gm...@gm...>
|