[Opensrf-commits] r1896 - trunk/src/perl/lib/OpenSRF/Utils (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Jan 19 13:41:28 EST 2010


Author: erickson
Date: 2010-01-19 13:41:24 -0500 (Tue, 19 Jan 2010)
New Revision: 1896

Modified:
   trunk/src/perl/lib/OpenSRF/Utils/Logger.pm
Log:

Patch from Joe Atzberger:

When running from command-line, logger warns "Logger found no config.  Using STDERR" but in fact fails to do so.  That blocks atomic testing of dependent modules, including almost all of EG's Application and Utils.  

Also, in _write_file when failing to sysopen the target file, the die message reports a different variable than the one actually targeted.  



Modified: trunk/src/perl/lib/OpenSRF/Utils/Logger.pm
===================================================================
--- trunk/src/perl/lib/OpenSRF/Utils/Logger.pm	2010-01-19 04:43:00 UTC (rev 1895)
+++ trunk/src/perl/lib/OpenSRF/Utils/Logger.pm	2010-01-19 18:41:24 UTC (rev 1896)
@@ -251,20 +251,22 @@
 	}
 }
 
-
 sub _write_file {
-	my( $msg, $isact) = @_;
-	my $file = $logfile;
-	$file = $actfile if $isact;
+	my ($msg, $isact) = @_;
+	my $file = $isact ? $actfile : $logfile;
 	my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);  
 	$year += 1900; $mon += 1;
-	sysopen( SINK, $file, O_NONBLOCK|O_WRONLY|O_APPEND|O_CREAT ) 
-		or die "Cannot sysopen $logfile: $!";
+
+    if ($file) {
+        sysopen( SINK, $file, O_NONBLOCK|O_WRONLY|O_APPEND|O_CREAT ) 
+            or die "Cannot sysopen $file: $!";
+    } else {
+        open (SINK, ">&2");  # print to STDERR as warned
+    }
 	binmode(SINK, ':utf8');
 	printf SINK "[%04d-%02d-%02d %02d:%02d:%02d] %s %s\n", $year, $mon, $mday, $hour, $min, $sec, $service, $msg;
 	close( SINK );
 }
 
+1;
 
-
-1;



More information about the opensrf-commits mailing list