[8390] Fixed log output work after recent replace UTF8PRINT macro. Author: VladimirMangos

--HG--
branch : trunk
This commit is contained in:
megamage
2009-08-19 17:14:18 -05:00
parent c911772125
commit 34a95e7fa8
3 changed files with 60 additions and 26 deletions

View File

@@ -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);

View File

@@ -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
}

View File

@@ -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);