[Opensrf-commits] r977 - trunk/src/libopensrf

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Jun 25 23:07:09 EDT 2007


Author: miker
Date: 2007-06-25 23:04:37 -0400 (Mon, 25 Jun 2007)
New Revision: 977

Modified:
   trunk/src/libopensrf/log.c
Log:
Patch from Scott McKellar, finishing off the "log to stderr when all esle fails" work:

Currently if we have asked to log to a file, but we haven't yet
specified the name of that log file, then any messages issued are
dropped.

With this patch, any messages issued under these conditions will be
rerouted to standard error.  The rerouting is only temporary,
applying only to the current message.



Modified: trunk/src/libopensrf/log.c
===================================================================
--- trunk/src/libopensrf/log.c	2007-06-25 20:48:18 UTC (rev 976)
+++ trunk/src/libopensrf/log.c	2007-06-26 03:04:37 UTC (rev 977)
@@ -195,7 +195,14 @@
 
    char* xid = (_osrfLogXid) ? _osrfLogXid : "";
 
-	if(_osrfLogType == OSRF_LOG_TYPE_SYSLOG ) {
+   int logtype = _osrfLogType;
+   if( logtype == OSRF_LOG_TYPE_FILE && !_osrfLogFile )
+   {
+	   // No log file defined?  Temporarily reroute to stderr
+	   logtype = OSRF_LOG_TYPE_STDERR;
+   }
+
+   if( logtype == OSRF_LOG_TYPE_SYSLOG ) {
 		char buf[1536];  
 		memset(buf, 0x0, 1536);
 		/* give syslog some breathing room, and be cute about it */
@@ -207,10 +214,10 @@
 		syslog( fac | lvl, "[%s:%ld:%s:%d:%s] %s", label, (long) getpid(), filename, line, xid, buf );
 	}
 
-	else if( _osrfLogType == OSRF_LOG_TYPE_FILE )
+	else if( logtype == OSRF_LOG_TYPE_FILE )
 		_osrfLogToFile( "[%s:%ld:%s:%d:%s] %s", label, (long) getpid(), filename, line, xid, msg );
 
-	else if( _osrfLogType == OSRF_LOG_TYPE_STDERR )
+	else if( logtype == OSRF_LOG_TYPE_STDERR )
 		fprintf( stderr, "[%s:%ld:%s:%d:%s] %s\n", label, (long) getpid(), filename, line, xid, msg );
 }
 



More information about the opensrf-commits mailing list