Subject: | attempt to flush email during DESTROY |
Dear maintainer,
Log::Log4perl may use Log::Dispatch::Email as dispatcher. Probably something is wrong
there, which causes some message not get sent. This situation is handled by ::Email.
Maybe you can improve this:
Can't locate object method "open" via package "Mail::Mailer::sendmail" at xxx/perl-5.16.3
/lib/site_perl/5.16.3/Mail/Send.pm line 58 during global destruction.
This is caused because DESTROY calls flush(), which calls $self->send_email when there is
something in the buffer. And send_email() uses an other object which is already cleaned-up.
May I suggest an improvement?
use Devel::GlobalDestruction qw/in_global_destruction/;
sub DESTROY {
my $self = shift;
if(in_global_destruction)
{ die "message not sent, while program terminates"
if @{$self->{buffer} || []};
}
else
{ $self->flush;
}
}