>How do I log die errors and exit nicely.

Hi,you could re-defined signal die handler,for example:

$SIG{__DIE__}=\&log_die;
sub log_die
{
    my $time=scalar localtime;
    open (HDW,">>",$err_log);
    print HDW $time,"  ",@_;
    close HDW;
    die @_;
}


when your program call the 'die',it should execute the function 'log_die',which 
write the die-infos to logfile,then die nicely.for example:

open (HD,"log.txt") or die $!;

when the program meet this 'die',it should call the 'log_die' handler,and write 
the die-infos stored in "$!" variable to the $err_log file.and the notice 
is,the second 'die' in the handler should never get re-defined,it should 'die' 
as normally as others.

HTH.

--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to