fixed problems with directory only listing privates for you
[spider.git] / perl / DXDebug.pm
index e19f309ca76cddb7285ed6b2aefa8aa7e2bfe1a7..c44ba35920f5d049291a4021b78b845c1406a606 100644 (file)
@@ -11,8 +11,8 @@ package DXDebug;
 
 require Exporter;
 @ISA = qw(Exporter);
-@EXPORT = qw(dbg dbgadd dbgsub dbglist isdbg);
-@EXPORT_OK = qw(dbg dbgadd dbgsub dbglist isdbg);
+@EXPORT = qw(dbg dbgadd dbgsub dbglist isdbg dbgclose);
+@EXPORT_OK = qw(dbg dbgadd dbgsub dbglist isdbg dbgclose);
 
 use strict;
 use vars qw(%dbglevel $fp);
@@ -25,6 +25,23 @@ use Carp;
 %dbglevel = ();
 $fp = DXLog::new('debug', 'dat', 'd');
 
+# add sig{__DIE__} handling
+if (!defined $DB::VERSION) {
+       $SIG{__WARN__} = $SIG{__DIE__} = sub { 
+               my $t = time; 
+               for (@_) {
+                       $fp->writeunix($t, "$t^$_"); 
+#                      print STDERR $_;
+               }
+       };
+}
+
+sub dbgclose
+{
+       $SIG{__DIE__} = $SIG{__WARN__} = 'DEFAULT';
+       $fp->close();
+}
+
 sub dbg
 {
        my $l = shift;