diff options
author | megamage <none@none> | 2009-08-19 17:14:18 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-08-19 17:14:18 -0500 |
commit | 34a95e7fa882f702e50305b9bc726d5b86c7e63b (patch) | |
tree | 2ad0c1e9e29b1224abe28d2f9e91766fa7eaa3dd /src | |
parent | c9117721255b24d86f00b3f94c6f112fefa5bfdd (diff) |
[8390] Fixed log output work after recent replace UTF8PRINT macro. Author: VladimirMangos
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/Log.cpp | 67 | ||||
-rw-r--r-- | src/shared/Util.cpp | 18 | ||||
-rw-r--r-- | src/shared/Util.h | 1 |
3 files changed, 60 insertions, 26 deletions
diff --git a/src/shared/Log.cpp b/src/shared/Log.cpp index 32483486628..0ddcc69fe28 100644 --- a/src/shared/Log.cpp +++ b/src/shared/Log.cpp @@ -388,7 +388,11 @@ void Log::outString( const char * str, ... ) if(m_colored) SetColor(true,m_colors[LOGL_NORMAL]); - utf8printf(stdout, str); + va_list ap; + + va_start(ap, str); + vutf8printf(stdout, str, &ap); + va_end(ap); if(m_colored) ResetColor(true); @@ -397,7 +401,6 @@ void Log::outString( const char * str, ... ) if(logfile) { outTimestamp(logfile); - va_list ap; va_start(ap, str); vfprintf(logfile, str, ap); fprintf(logfile, "\n" ); @@ -438,7 +441,11 @@ void Log::outCrash( const char * err, ... ) if(m_colored) SetColor(false,RED); - utf8printf(stdout, err); + va_list ap; + + va_start(ap, err); + vutf8printf(stdout, err, &ap); + va_end(ap); if(m_colored) ResetColor(false); @@ -449,7 +456,6 @@ void Log::outCrash( const char * err, ... ) outTimestamp(logfile); fprintf(logfile, "CRASH ALERT: " ); - va_list ap; va_start(ap, err); vfprintf(logfile, err, ap); va_end(ap); @@ -478,7 +484,11 @@ void Log::outError( const char * err, ... ) if(m_colored) SetColor(false,RED); - utf8printf(stderr, err); + va_list ap; + + va_start(ap, err); + vutf8printf(stderr, err, &ap); + va_end(ap); if(m_colored) ResetColor(false); @@ -489,7 +499,6 @@ void Log::outError( const char * err, ... ) outTimestamp(logfile); fprintf(logfile, "ERROR: " ); - va_list ap; va_start(ap, err); vfprintf(logfile, err, ap); va_end(ap); @@ -526,7 +535,11 @@ void Log::outErrorDb( const char * err, ... ) if(m_colored) SetColor(false,RED); - utf8printf(stderr, err); + va_list ap; + + va_start(ap, err); + vutf8printf(stderr, err, &ap); + va_end(ap); if(m_colored) ResetColor(false); @@ -538,7 +551,6 @@ void Log::outErrorDb( const char * err, ... ) outTimestamp(logfile); fprintf(logfile, "ERROR: " ); - va_list ap; va_start(ap, err); vfprintf(logfile, err, ap); va_end(ap); @@ -550,7 +562,6 @@ void Log::outErrorDb( const char * err, ... ) if(dberLogfile) { outTimestamp(dberLogfile); - va_list ap; va_start(ap, err); vfprintf(dberLogfile, err, ap); va_end(ap); @@ -581,7 +592,10 @@ void Log::outBasic( const char * str, ... ) if(m_colored) SetColor(true,m_colors[LOGL_BASIC]); - utf8printf(stdout, str); + va_list ap; + va_start(ap, str); + vutf8printf(stdout, str, &ap); + va_end(ap); if(m_colored) ResetColor(true); @@ -622,7 +636,10 @@ void Log::outDetail( const char * str, ... ) if(m_colored) SetColor(true,m_colors[LOGL_DETAIL]); - utf8printf(stdout, str); + va_list ap; + va_start(ap, str); + vutf8printf(stdout, str, &ap); + va_end(ap); if(m_colored) ResetColor(true); @@ -635,8 +652,9 @@ void Log::outDetail( const char * str, ... ) va_list ap; va_start(ap, str); vfprintf(logfile, str, ap); - fprintf(logfile, "\n" ); va_end(ap); + + fprintf(logfile, "\n" ); fflush(logfile); } @@ -650,7 +668,13 @@ void Log::outDebugInLine( const char * str, ... ) if( m_logLevel > LOGL_DETAIL ) { - utf8printf(stdout, str); + va_list ap; + va_start(ap, str); + vutf8printf(stdout, str, &ap); + va_end(ap); + + //if(m_colored) + // ResetColor(true); } if(logfile && m_logFileLevel > LOGL_DETAIL) { @@ -681,7 +705,10 @@ void Log::outDebug( const char * str, ... ) if(m_colored) SetColor(true,m_colors[LOGL_DEBUG]); - utf8printf(stdout, str); + va_list ap; + va_start(ap, str); + vutf8printf(stdout, str, &ap); + va_end(ap); if(m_colored) ResetColor(true); @@ -707,11 +734,14 @@ void Log::outStringInLine( const char * str, ... ) if( !str ) return; - utf8printf(stdout, str); + va_list ap; + + va_start(ap, str); + vutf8printf(stdout, str, &ap); + va_end(ap); if(logfile) { - va_list ap; va_start(ap, str); vfprintf(logfile, str, ap); va_end(ap); @@ -739,7 +769,10 @@ void Log::outCommand( uint32 account, const char * str, ... ) if(m_colored) SetColor(true,m_colors[LOGL_BASIC]); - utf8printf(stdout, str); + va_list ap; + va_start(ap, str); + vutf8printf(stdout, str, &ap); + va_end(ap); if(m_colored) ResetColor(true); diff --git a/src/shared/Util.cpp b/src/shared/Util.cpp index 3d3b205209a..5b52857f55a 100644 --- a/src/shared/Util.cpp +++ b/src/shared/Util.cpp @@ -481,25 +481,25 @@ bool Utf8FitTo(const std::string& str, std::wstring search) void utf8printf(FILE *out, const char *str, ...) { va_list ap; + va_start(ap, str); + vutf8printf(stdout, str, &ap); + va_end(ap); +} +void vutf8printf(FILE *out, const char *str, va_list* ap) +{ #if PLATFORM == PLATFORM_WINDOWS char temp_buf[32*1024]; wchar_t wtemp_buf[32*1024]; - size_t temp_len; - size_t wtemp_len; - va_start(ap, str); - temp_len = vsnprintf(temp_buf, 32*1024, str, ap); - va_end(ap); + size_t temp_len = vsnprintf(temp_buf, 32*1024, str, *ap); - wtemp_len = 32*1024-1; + size_t wtemp_len = 32*1024-1; Utf8toWStr(temp_buf, temp_len, wtemp_buf, wtemp_len); CharToOemBuffW(&wtemp_buf[0], &temp_buf[0], wtemp_len+1); fprintf(out, temp_buf); #else - va_start(ap, str); - vfprintf(out, str, ap); - va_end(ap); + vfprintf(out, str, *ap); #endif } diff --git a/src/shared/Util.h b/src/shared/Util.h index a57c7b2a2f4..91f7c95b5ab 100644 --- a/src/shared/Util.h +++ b/src/shared/Util.h @@ -286,6 +286,7 @@ bool utf8ToConsole(const std::string& utf8str, std::string& conStr); bool consoleToUtf8(const std::string& conStr,std::string& utf8str); bool Utf8FitTo(const std::string& str, std::wstring search); void utf8printf(FILE *out, const char *str, ...); +void vutf8printf(FILE *out, const char *str, va_list* ap); bool IsIPAddress(char const* ipaddress); uint32 CreatePIDFile(const std::string& filename); |