aboutsummaryrefslogtreecommitdiff
path: root/src/logger.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-10-24 00:57:18 +0000
committerMike Buland <eichlan@xagasoft.com>2007-10-24 00:57:18 +0000
commitd1770f567321f8b01185cdf974718aea89669a37 (patch)
treea76ddcb795b99ecd880824c06f505101bf4388a1 /src/logger.cpp
parentae5ea621f06a645dbfcf454e9b8f39a99dc8e822 (diff)
downloadlibbu++-d1770f567321f8b01185cdf974718aea89669a37.tar.gz
libbu++-d1770f567321f8b01185cdf974718aea89669a37.tar.bz2
libbu++-d1770f567321f8b01185cdf974718aea89669a37.tar.xz
libbu++-d1770f567321f8b01185cdf974718aea89669a37.zip
Corrected a few issues that cropped up when using the Bu::Socket without a
Client for buffering. The Bu::Client has also been made a little more reliable. The logger should get a few more tweaks, but it works fine for now, the hex dump could stand another tweak or two.
Diffstat (limited to '')
-rw-r--r--src/logger.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/logger.cpp b/src/logger.cpp
index fe6a916..91679ff 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -20,7 +20,11 @@ void Bu::Logger::log( uint32_t nLevel, const char *sFile, const char *sFunction,
20 va_list ap; 20 va_list ap;
21 va_start( ap, sFormat ); 21 va_start( ap, sFormat );
22 char *text; 22 char *text;
23 vasprintf( &text, sFormat, ap ); 23 if( vasprintf( &text, sFormat, ap ) < 0 )
24 {
25 printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WTF?\n");
26 return;
27 }
24 va_end(ap); 28 va_end(ap);
25 29
26 time_t t = time(NULL); 30 time_t t = time(NULL);
@@ -152,6 +156,11 @@ void Bu::Logger::hexDump( uint32_t nLevel, const char *sFile,
152 Bu::FString sLine; 156 Bu::FString sLine;
153 for(;;) 157 for(;;)
154 { 158 {
159 {
160 char buf[15];
161 sprintf( buf, "%010d| ", j );
162 sLine += buf;
163 }
155 int kmax = 8; 164 int kmax = 8;
156 if( nDataLen-j < 8 ) kmax = nDataLen-j; 165 if( nDataLen-j < 8 ) kmax = nDataLen-j;
157 for(int k = 0; k < 8; k++ ) 166 for(int k = 0; k < 8; k++ )
@@ -171,7 +180,7 @@ void Bu::Logger::hexDump( uint32_t nLevel, const char *sFile,
171 for(int k = 0; k < kmax; k++ ) 180 for(int k = 0; k < kmax; k++ )
172 { 181 {
173 char buf[3]; 182 char buf[3];
174 sprintf( buf, "%c ", (pData[j+k]>32 && pData[j+k]<=128)?(pData[j+k]):('.') ); 183 sprintf( buf, "%c", (pData[j+k]>32 && pData[j+k]<=128)?(pData[j+k]):('.') );
175 sLine += buf; 184 sLine += buf;
176 } 185 }
177 log( nLevel, sFile, sFunction, nLine, sLine.getStr() ); 186 log( nLevel, sFile, sFunction, nLine, sLine.getStr() );