From 3562f612d1d1eddd58bdf5904fc66bbf36df4e79 Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 9 Dec 2005 14:55:43 +0000 Subject: [PATCH] re-arranged the log code so that VA_LIST_TO_ARGS (which runs vsnprintf) will only have to be called once per log. This appears to make vsnprintf happy with regard to printing embedded %'s Happily printing the URL's in the gateway now git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@607 9efc2488-bf62-4759-914b-345cdb29e865 --- src/gateway/mod_ils_gateway.c | 1 + src/utils/log.c | 12 ++++++++---- src/utils/log.h | 5 ++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/gateway/mod_ils_gateway.c b/src/gateway/mod_ils_gateway.c index 82a9a3c..1d030e8 100644 --- a/src/gateway/mod_ils_gateway.c +++ b/src/gateway/mod_ils_gateway.c @@ -118,6 +118,7 @@ static int mod_ils_gateway_method_handler (request_rec *r) { return OK; } + osrfLogDebug("URL: %s", arg ); ap_log_rerror( APLOG_MARK, APLOG_DEBUG, 0, r, "URL: %s", arg ); r->allowed |= (AP_METHOD_BIT << M_GET); diff --git a/src/utils/log.c b/src/utils/log.c index 03c8809..c07535f 100644 --- a/src/utils/log.c +++ b/src/utils/log.c @@ -71,6 +71,12 @@ void osrfLogActivity( const char* msg, ... ) { } void osrfLogDetail( int level, char* filename, int line, char* func, char* msg, ... ) { + if(!msg) return; + VA_LIST_TO_STRING(msg); + _osrfLogDetail( level, filename, line, func, VA_BUF ); +} + +void _osrfLogDetail( int level, char* filename, int line, char* func, char* msg ) { if( level == OSRF_LOG_ACTIVITY && ! __osrfLogActivityEnabled ) return; if( level > __osrfLogLevel ) return; @@ -119,13 +125,11 @@ void osrfLogDetail( int level, char* filename, int line, char* func, char* msg, break; } - VA_LIST_TO_STRING(msg); - if(__osrfLogType == OSRF_LOG_TYPE_SYSLOG ) - syslog( fac | lvl, "[%s:%d:%s:%s:%s] %s", l, getpid(), filename, lb, func, VA_BUF ); + syslog( fac | lvl, "[%s:%d:%s:%s:%s] %s", l, getpid(), filename, lb, func, msg ); else if( __osrfLogType == OSRF_LOG_TYPE_FILE ) - _osrfLogToFile("[%s:%d:%s:%s:%s] %s", l, getpid(), filename, lb, func, VA_BUF ); + _osrfLogToFile("[%s:%d:%s:%s:%s] %s", l, getpid(), filename, lb, func, msg ); } diff --git a/src/utils/log.h b/src/utils/log.h index 3933ca6..68efc39 100644 --- a/src/utils/log.h +++ b/src/utils/log.h @@ -22,7 +22,7 @@ #define OSRF_LOG_GO(m,l) \ if(!m) return; \ VA_LIST_TO_STRING(m); \ - osrfLogDetail( l, NULL, -1, NULL, VA_BUF ); + _osrfLogDetail( l, NULL, -1, NULL, VA_BUF ); @@ -61,6 +61,9 @@ void osrfLogSetActivityEnabled( int enabled ); * and function name in addition to the usual level and message */ void osrfLogDetail( int level, char* filename, int line, char* func, char* msg, ... ); +/** Actually does the logging */ +void _osrfLogDetail( int level, char* filename, int line, char* func, char* msg ); + void _osrfLogToFile( char* msg, ... ); /* returns the int representation of the log facility based on the facility name -- 2.11.0