in reply to Capturing Text from a die command
A more robust solution is to maintain a list of active Logger instances within the package, and set up just one die handler that writes to all of them.package Logger; sub new { my $self = ... ... $SIG{__DIE__} = sub { my $msg = shift; $self->add($msg); die $msg; }; return $self; }
You may also want to take care to not clobber existing die handlers, but I don't know a whole lot about that. I'll leave it to the pros ;)package Logger; our @instances; sub new { my $self = ...; ... push @instances, $self; return $self; } $SIG{__DIE__} = sub { my $msg = shift; $_->add($msg) for @instances; }
blokhead
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Capturing Text from a die command
by or10n (Initiate) on May 14, 2004 at 18:24 UTC | |
|
Re: Re: Capturing Text from a die command
by hv (Prior) on May 16, 2004 at 13:13 UTC |