From 0ae528775dbb113e537ee8975b6450838412f0bc Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Wed, 19 Aug 2009 01:56:20 +0400 Subject: [PATCH] [8390] Fixed log output work after recent replace UTF8PRINT macro. --- src/shared/Log.cpp | 59 ++++++++++++++++++++++++++++++---------- src/shared/Util.cpp | 18 ++++++------ src/shared/Util.h | 1 + src/shared/revision_nr.h | 2 +- 4 files changed, 55 insertions(+), 25 deletions(-) diff --git a/src/shared/Log.cpp b/src/shared/Log.cpp index d2d09e34f..a4166dcee 100644 --- a/src/shared/Log.cpp +++ b/src/shared/Log.cpp @@ -369,7 +369,11 @@ void Log::outString( const char * str, ... ) if(m_includeTime) outTime(); - utf8printf(stdout, str); + va_list ap; + + va_start(ap, str); + vutf8printf(stdout, str, &ap); + va_end(ap); if(m_colored) ResetColor(true); @@ -379,7 +383,6 @@ void Log::outString( const char * str, ... ) { outTimestamp(logfile); - va_list ap; va_start(ap, str); vfprintf(logfile, str, ap); fprintf(logfile, "\n" ); @@ -401,7 +404,11 @@ void Log::outError( const char * err, ... ) if(m_includeTime) outTime(); - utf8printf(stderr, err); + va_list ap; + + va_start(ap, err); + vutf8printf(stderr, err, &ap); + va_end(ap); if(m_colored) ResetColor(false); @@ -412,7 +419,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); @@ -434,7 +440,11 @@ void Log::outErrorDb( const char * err, ... ) if(m_includeTime) outTime(); - utf8printf(stderr, err); + va_list ap; + + va_start(ap, err); + vutf8printf(stderr, err, &ap); + va_end(ap); if(m_colored) ResetColor(false); @@ -446,7 +456,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); @@ -483,7 +492,10 @@ void Log::outBasic( const char * str, ... ) if(m_includeTime) outTime(); - utf8printf(stdout, str); + va_list ap; + va_start(ap, str); + vutf8printf(stdout, str, &ap); + va_end(ap); if(m_colored) ResetColor(true); @@ -518,7 +530,10 @@ void Log::outDetail( const char * str, ... ) if(m_includeTime) outTime(); - utf8printf(stdout, str); + va_list ap; + va_start(ap, str); + vutf8printf(stdout, str, &ap); + va_end(ap); if(m_colored) ResetColor(true); @@ -527,12 +542,14 @@ void Log::outDetail( const char * str, ... ) } if(logfile && m_logFileLevel > 1) { - va_list ap; outTimestamp(logfile); + + va_list ap; va_start(ap, str); vfprintf(logfile, str, ap); - fprintf(logfile, "\n" ); va_end(ap); + + fprintf(logfile, "\n" ); fflush(logfile); } @@ -548,7 +565,10 @@ void Log::outDebugInLine( const char * str, ... ) if(m_colored) SetColor(true,m_colors[LogDebug]); - utf8printf(stdout, str); + va_list ap; + va_start(ap, str); + vutf8printf(stdout, str, &ap); + va_end(ap); if(m_colored) ResetColor(true); @@ -574,7 +594,10 @@ void Log::outDebug( const char * str, ... ) if(m_includeTime) outTime(); - utf8printf(stdout, str); + va_list ap; + va_start(ap, str); + vutf8printf(stdout, str, &ap); + va_end(ap); if(m_colored) ResetColor(true); @@ -609,7 +632,10 @@ void Log::outCommand( uint32 account, const char * str, ... ) if(m_includeTime) outTime(); - utf8printf(stdout, str); + va_list ap; + va_start(ap, str); + vutf8printf(stdout, str, &ap); + va_end(ap); if(m_colored) ResetColor(true); @@ -691,7 +717,11 @@ void Log::outMenu( const char * str, ... ) if(m_includeTime) outTime(); - utf8printf(stdout, str); + va_list ap; + + va_start(ap, str); + vutf8printf(stdout, str, &ap); + va_end(ap); ResetColor(true); @@ -699,7 +729,6 @@ void Log::outMenu( const char * str, ... ) { outTimestamp(logfile); - va_list ap; va_start(ap, str); vfprintf(logfile, str, ap); va_end(ap); diff --git a/src/shared/Util.cpp b/src/shared/Util.cpp index 0ca1d3310..d4183eb3e 100644 --- a/src/shared/Util.cpp +++ b/src/shared/Util.cpp @@ -423,25 +423,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 6a99ee8c4..522c917d9 100644 --- a/src/shared/Util.h +++ b/src/shared/Util.h @@ -284,6 +284,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); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index c428f9f73..ff9b017fd 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8389" + #define REVISION_NR "8390" #endif // __REVISION_NR_H__