1. cluster seems to have a memory leak, put DESTROY functions in where
[spider.git] / perl / DXLog.pm
index 8cc6f8504b35a842304b2443e1f3d9ac23dc3d23..f089d73d0cecc28058bfd975eaf47df79d207ab5 100644 (file)
@@ -27,7 +27,7 @@ package DXLog;
 
 require Exporter;
 @ISA = qw(Exporter);
-@EXPORT = qw(Log);
+@EXPORT = qw(Log Logclose);
 
 use FileHandle;
 use DXVars;
@@ -161,7 +161,14 @@ sub close
 {
        my $self = shift;
        undef $self->{fh};                      # close the filehandle
-       delete $self->{fh};
+       delete $self->{fh};     
+}
+
+sub DESTROY
+{
+       my $self = shift;
+       undef $self->{fh};                      # close the filehandle
+       delete $self->{fh} if $self->{fh};
 }
 
 # log something in the system log 
@@ -174,10 +181,8 @@ sub Log
        $log->writeunix($t, join('^', $t, @_) );
 }
 
-sub DESTROY                                            # catch undefs and do what is required further down the tree
+sub Logclose
 {
-       my $self = shift;
-       DXDebug::dbg("dxlog", "closing $self->{fn}\n");
-       undef $self->{fh} if defined $self->{fh};
-} 
+       $log->close();
+}
 1;