From: erickson Date: Tue, 19 Jan 2010 18:41:24 +0000 (+0000) Subject: Patch from Joe Atzberger: X-Git-Tag: osrf_rel_2_0_1~194 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=aca64c95fc7b98d3f0a3ad6b8b8c55e4627d4491;p=OpenSRF.git 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. git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1896 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/perl/lib/OpenSRF/Utils/Logger.pm b/src/perl/lib/OpenSRF/Utils/Logger.pm index e911224..76f1534 100644 --- a/src/perl/lib/OpenSRF/Utils/Logger.pm +++ b/src/perl/lib/OpenSRF/Utils/Logger.pm @@ -251,20 +251,22 @@ sub _log_message { } } - 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; +