[Opensrf-commits] r1694 - trunk/src/libopensrf (scottmk)

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Apr 26 21:44:10 EDT 2009


Author: scottmk
Date: 2009-04-26 21:44:08 -0400 (Sun, 26 Apr 2009)
New Revision: 1694

Modified:
   trunk/src/libopensrf/log.c
Log:
Performance tweak for osrfLog* functions: don't pass the message
through VA_LIST_TO_STRING unless you're actually going to use it.


Modified: trunk/src/libopensrf/log.c
===================================================================
--- trunk/src/libopensrf/log.c	2009-04-08 02:48:02 UTC (rev 1693)
+++ trunk/src/libopensrf/log.c	2009-04-27 01:44:08 UTC (rev 1694)
@@ -20,11 +20,6 @@
 static void _osrfLogToFile( const char* msg, ... );
 static void _osrfLogSetXid( const char* xid );
 
-#define OSRF_LOG_GO(f,li,m,l)	\
-        if(!m) return;		\
-        VA_LIST_TO_STRING(m);	\
-        _osrfLogDetail( l, f, li, VA_BUF );
-
 void osrfLogCleanup( void ) {
 	free(_osrfLogAppname);
 	_osrfLogAppname = NULL;
@@ -153,27 +148,60 @@
 	return _osrfLogLevel;
 }
 
-void osrfLogError( const char* file, int line, const char* msg, ... ) 
-	{ OSRF_LOG_GO(file, line, msg, OSRF_LOG_ERROR); }
-void osrfLogWarning( const char* file, int line, const char* msg, ... ) 
-	{ OSRF_LOG_GO(file, line, msg, OSRF_LOG_WARNING); }
-void osrfLogInfo( const char* file, int line, const char* msg, ... ) 
-	{ OSRF_LOG_GO(file, line, msg, OSRF_LOG_INFO); }
-void osrfLogDebug( const char* file, int line, const char* msg, ... ) 
-	{ OSRF_LOG_GO(file, line, msg, OSRF_LOG_DEBUG); }
-void osrfLogInternal( const char* file, int line, const char* msg, ... ) 
-	{ OSRF_LOG_GO(file, line, msg, OSRF_LOG_INTERNAL); }
-void osrfLogActivity( const char* file, int line, const char* msg, ... ) { 
-	OSRF_LOG_GO(file, line, msg, OSRF_LOG_ACTIVITY); 
-	_osrfLogDetail( OSRF_LOG_INFO, file, line, VA_BUF ); /* also log at info level */
+void osrfLogError( const char* file, int line, const char* msg, ... ) {
+	if( !msg ) return;
+	if( _osrfLogLevel < OSRF_LOG_ERROR ) return;
+	VA_LIST_TO_STRING( msg );
+	_osrfLogDetail( OSRF_LOG_ERROR, file, line, VA_BUF );
 }
 
+void osrfLogWarning( const char* file, int line, const char* msg, ... ) {
+	if( !msg ) return;
+	if( _osrfLogLevel < OSRF_LOG_WARNING ) return;
+	VA_LIST_TO_STRING( msg );
+	_osrfLogDetail( OSRF_LOG_WARNING, file, line, VA_BUF );
+}
+
+void osrfLogInfo( const char* file, int line, const char* msg, ... ) {
+	if( !msg ) return;
+	if( _osrfLogLevel < OSRF_LOG_INFO ) return;
+	VA_LIST_TO_STRING( msg );
+	_osrfLogDetail( OSRF_LOG_INFO, file, line, VA_BUF );
+}
+
+void osrfLogDebug( const char* file, int line, const char* msg, ... ) {
+	if( !msg ) return;
+	if( _osrfLogLevel < OSRF_LOG_DEBUG ) return;
+	VA_LIST_TO_STRING( msg );
+	_osrfLogDetail( OSRF_LOG_DEBUG, file, line, VA_BUF );
+}
+
+void osrfLogInternal( const char* file, int line, const char* msg, ... ) {
+	if( !msg ) return;
+	if( _osrfLogLevel < OSRF_LOG_INTERNAL ) return;
+	VA_LIST_TO_STRING( msg );
+	_osrfLogDetail( OSRF_LOG_INTERNAL, file, line, VA_BUF );
+}
+
+void osrfLogActivity( const char* file, int line, const char* msg, ... ) {
+	if( !msg ) return;
+	if( _osrfLogLevel >= OSRF_LOG_INFO
+		|| ( _osrfLogActivityEnabled && _osrfLogLevel >= OSRF_LOG_ACTIVITY ) )
+	{
+		VA_LIST_TO_STRING( msg );
+
+		if( _osrfLogActivityEnabled && _osrfLogLevel >= OSRF_LOG_ACTIVITY )
+			_osrfLogDetail( OSRF_LOG_ACTIVITY, file, line, VA_BUF );
+
+		/* also log at info level */
+		if( _osrfLogLevel >= OSRF_LOG_INFO )
+			_osrfLogDetail( OSRF_LOG_INFO, file, line, VA_BUF );
+	}
+}
+
 /** Actually does the logging */
 static void _osrfLogDetail( int level, const char* filename, int line, char* msg ) {
 
-	if( level == OSRF_LOG_ACTIVITY && ! _osrfLogActivityEnabled ) return;
-	if( level > _osrfLogLevel ) return;
-	if(!msg) return;
 	if(!filename) filename = "";
 
 	char* label = "INFO";		/* level name */



More information about the opensrf-commits mailing list