|
|
|
@ -1,4 +1,5 @@ |
|
|
|
|
#include <set> |
|
|
|
|
#include <ctime> |
|
|
|
|
|
|
|
|
|
#include "globals.hpp" |
|
|
|
|
|
|
|
|
@ -41,3 +42,44 @@ void initLogging( const wchar_t* pLogging ) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool isLoggingEnabled( const string& s ) { return gLogging.find(s) != gLogging.end() ; } |
|
|
|
|
|
|
|
|
|
string |
|
|
|
|
makeLogMsg( const string& msg ) |
|
|
|
|
{ |
|
|
|
|
// prepare the log message
|
|
|
|
|
stringstream buf ; |
|
|
|
|
const char* p = msg.c_str() ; |
|
|
|
|
for ( ; ; ) |
|
|
|
|
{ |
|
|
|
|
// output the timestamp/tab
|
|
|
|
|
if ( p == msg.c_str() ) |
|
|
|
|
{ |
|
|
|
|
char buf2[80] ; |
|
|
|
|
time_t now = time( NULL ) ; |
|
|
|
|
struct tm tmNow ; |
|
|
|
|
(void) localtime_s( &tmNow , &now ) ; |
|
|
|
|
strftime( buf2 , sizeof(buf2) , "%d/%b/%y %H:%M:%S" , &tmNow ) ; |
|
|
|
|
for ( int i=0 ; buf2[i] != ' ' ; ++i ) |
|
|
|
|
buf2[i] = toupper( buf2[i] ) ; |
|
|
|
|
buf << buf2 ; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
buf << " " ; |
|
|
|
|
buf << " | " ; |
|
|
|
|
|
|
|
|
|
// output the next line
|
|
|
|
|
const char* q = strchr( p , '\n' ) ; |
|
|
|
|
if ( q == NULL ) |
|
|
|
|
{ |
|
|
|
|
buf << p << endl ; |
|
|
|
|
break ; // nb: this was the last line
|
|
|
|
|
} |
|
|
|
|
buf.write( p , q-p ) ; |
|
|
|
|
buf << endl ; |
|
|
|
|
p = q + 1 ; |
|
|
|
|
if ( *p == '\0' ) |
|
|
|
|
break ; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return buf.str() ; |
|
|
|
|
} |
|
|
|
|