X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXDebug.pm;fp=perl%2FDXDebug.pm;h=b55d01fcf5ea8de4fa060321e12195468274d8cc;hb=4a89177a94f3a5ca3f3a1d1231ae5cdd6abd5155;hp=ac452413555d4975dc3750bcaad5d120234fefaa;hpb=77393fe9b517e6307f47dc844d05afa2454bfba7;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) {