diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2007-06-29 01:59:26 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2007-06-29 01:59:26 +0000 |
| commit | 60bac0c9f558ab34c70f099db923204a84d51ffc (patch) | |
| tree | 09e04f2112aeffa214bce94519b1c959f0d503fc /src | |
| parent | ec8ed8b4b44c7b039e87faaa50bb4d503393d336 (diff) | |
| download | libbu++-60bac0c9f558ab34c70f099db923204a84d51ffc.tar.gz libbu++-60bac0c9f558ab34c70f099db923204a84d51ffc.tar.bz2 libbu++-60bac0c9f558ab34c70f099db923204a84d51ffc.tar.xz libbu++-60bac0c9f558ab34c70f099db923204a84d51ffc.zip | |
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.
Diffstat (limited to '')
| -rw-r--r-- | src/logger.cpp | 32 | ||||
| -rw-r--r-- | src/plugger.h | 8 | ||||
| -rw-r--r-- | src/tests/logger.cpp | 2 |
3 files changed, 26 insertions, 16 deletions
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 ) | |||
| 71 | if( *s == '%' ) | 71 | if( *s == '%' ) |
| 72 | { | 72 | { |
| 73 | sLogFormat += '%'; | 73 | sLogFormat += '%'; |
| 74 | s++; | 74 | Bu::FString sBuf; |
| 75 | for( int l = 0;; l++ ) | 75 | for(;;) |
| 76 | { | 76 | { |
| 77 | if( fmts[l][0] == '\0' ) | 77 | s++; |
| 78 | int l; | ||
| 79 | for( l = 0;; l++ ) | ||
| 78 | { | 80 | { |
| 79 | sLogFormat += *s; | 81 | if( fmts[l][0] == '\0' ) |
| 80 | break; | 82 | { |
| 83 | sBuf += *s; | ||
| 84 | break; | ||
| 85 | } | ||
| 86 | else if( *s == fmts[l][0] ) | ||
| 87 | { | ||
| 88 | sLogFormat += fmts[l][2]; | ||
| 89 | sLogFormat += fmts[l][3]; | ||
| 90 | sLogFormat += '$'; | ||
| 91 | sLogFormat += sBuf; | ||
| 92 | sLogFormat += fmts[l][1]; | ||
| 93 | break; | ||
| 94 | } | ||
| 81 | } | 95 | } |
| 82 | else if( *s == fmts[l][0] ) | 96 | if( fmts[l][0] != '\0' ) |
| 83 | { | ||
| 84 | sLogFormat += fmts[l][2]; | ||
| 85 | sLogFormat += fmts[l][3]; | ||
| 86 | sLogFormat += '$'; | ||
| 87 | sLogFormat += fmts[l][1]; | ||
| 88 | break; | 97 | break; |
| 89 | } | ||
| 90 | } | 98 | } |
| 91 | } | 99 | } |
| 92 | else | 100 | 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 | |||
| 116 | 116 | ||
| 117 | void registerExternalPlugin( const char *sFName, const char *sPluginName ) | 117 | void registerExternalPlugin( const char *sFName, const char *sPluginName ) |
| 118 | { | 118 | { |
| 119 | PluginReg *pReg = (PluginReg *)hPlugin[sPluginName]; | 119 | PluginReg *pReg; |
| 120 | if( pReg != NULL ) | 120 | try { |
| 121 | { | 121 | pReg = (PluginReg *)hPlugin[sPluginName]; |
| 122 | hPlugin.erase( sPluginName ); | 122 | hPlugin.erase( sPluginName ); |
| 123 | dlclose( pReg->dlHandle ); | 123 | dlclose( pReg->dlHandle ); |
| 124 | delete pReg; | 124 | delete pReg; |
| 125 | pReg = NULL; | 125 | pReg = NULL; |
| 126 | } catch( Bu::HashException &e ) | ||
| 127 | { | ||
| 126 | } | 128 | } |
| 127 | 129 | ||
| 128 | pReg = new PluginReg; | 130 | 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 | |||
| 19 | int main() | 19 | int main() |
| 20 | { | 20 | { |
| 21 | setLogLevel( 4 ); | 21 | setLogLevel( 4 ); |
| 22 | setLogFormat("%L: %y-%m-%d %h:%M:%s %f:%l:%F: %t"); | 22 | setLogFormat("%L: %y-%02m-%02d %h:%02M:%02s %f:%l:%F: %t"); |
| 23 | lineLog( 5, "Hey, error: %s", strerror( errno ) ); | 23 | lineLog( 5, "Hey, error: %s", strerror( errno ) ); |
| 24 | 24 | ||
| 25 | Thing gh; | 25 | Thing gh; |
