X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXDebug.pm;h=b55d01fcf5ea8de4fa060321e12195468274d8cc;hb=1491e268e8069080922896cd8ea67aee254f28d1;hp=ac452413555d4975dc3750bcaad5d120234fefaa;hpb=cdb2c0e3a1d778485f71d406a561b38ed5238dbc;p=spider.git diff --git a/perl/DXDebug.pm b/perl/DXDebug.pm index ac452413..b55d01fc 100644 --- a/perl/DXDebug.pm +++ b/perl/DXDebug.pm @@ -21,7 +21,7 @@ use DXLog (); use Carp qw(cluck); %dbglevel = (); -$fp = DXLog::new('debug', 'dat', 'd'); +$fp = undef; # Avoid generating "subroutine redefined" warnings with the following # hack (from CGI::Carp): @@ -71,18 +71,21 @@ sub dbginit $SIG{__WARN__} = sub { _store($@, Carp::shortmess(@_)); }; $SIG{__DIE__} = sub { _store($@, Carp::longmess(@_)); }; } + + $fp = DXLog::new('debug', 'dat', 'd'); } sub dbgclose { $SIG{__DIE__} = $SIG{__WARN__} = 'DEFAULT'; - $fp->close(); + $fp->close() if $fp; + undef $fp; } sub dbg { my $l = shift; - if ($dbglevel{$l} || $l eq 'err') { + if ($fp && ($dbglevel{$l} || $l eq 'err')) { my @in = @_; my $t = time; for (@in) {