From 60bac0c9f558ab34c70f099db923204a84d51ffc Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 29 Jun 2007 01:59:26 +0000 Subject: The plugger was dying on a HashException it should have caught, and the Logger now allows you to include extra printf formatting in your fields just like the docs say you can. --- src/logger.cpp | 32 ++++++++++++++++++++------------ src/plugger.h | 8 +++++--- src/tests/logger.cpp | 2 +- 3 files changed, 26 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/logger.cpp b/src/logger.cpp index 848dfb1..1fc2262 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -71,22 +71,30 @@ void Bu::Logger::setFormat( const Bu::FString &str ) if( *s == '%' ) { sLogFormat += '%'; - s++; - for( int l = 0;; l++ ) + Bu::FString sBuf; + for(;;) { - if( fmts[l][0] == '\0' ) + s++; + int l; + for( l = 0;; l++ ) { - sLogFormat += *s; - break; + if( fmts[l][0] == '\0' ) + { + sBuf += *s; + break; + } + else if( *s == fmts[l][0] ) + { + sLogFormat += fmts[l][2]; + sLogFormat += fmts[l][3]; + sLogFormat += '$'; + sLogFormat += sBuf; + sLogFormat += fmts[l][1]; + break; + } } - else if( *s == fmts[l][0] ) - { - sLogFormat += fmts[l][2]; - sLogFormat += fmts[l][3]; - sLogFormat += '$'; - sLogFormat += fmts[l][1]; + if( fmts[l][0] != '\0' ) break; - } } } else diff --git a/src/plugger.h b/src/plugger.h index 615a662..2124b7a 100644 --- a/src/plugger.h +++ b/src/plugger.h @@ -116,13 +116,15 @@ namespace Bu void registerExternalPlugin( const char *sFName, const char *sPluginName ) { - PluginReg *pReg = (PluginReg *)hPlugin[sPluginName]; - if( pReg != NULL ) - { + PluginReg *pReg; + try { + pReg = (PluginReg *)hPlugin[sPluginName]; hPlugin.erase( sPluginName ); dlclose( pReg->dlHandle ); delete pReg; pReg = NULL; + } catch( Bu::HashException &e ) + { } pReg = new PluginReg; diff --git a/src/tests/logger.cpp b/src/tests/logger.cpp index a271443..290f479 100644 --- a/src/tests/logger.cpp +++ b/src/tests/logger.cpp @@ -19,7 +19,7 @@ class Thing int main() { setLogLevel( 4 ); - setLogFormat("%L: %y-%m-%d %h:%M:%s %f:%l:%F: %t"); + setLogFormat("%L: %y-%02m-%02d %h:%02M:%02s %f:%l:%F: %t"); lineLog( 5, "Hey, error: %s", strerror( errno ) ); Thing gh; -- cgit v1.2.3