From 6d0ddb6a6b27799219837cc2c7b7b6a2231e6afc Mon Sep 17 00:00:00 2001 From: sveith Date: Tue, 7 Apr 2009 17:50:26 +0000 Subject: [PATCH] * Fixed log output truncating the last byte in each message * Fixed log output for Release builds (NDEBUG) * Synchronized VS2005/VS2008 preprocessor definitions --- lib/base/CLog.cpp | 27 ++++++++++++++++----------- vs2005/client/client.vcproj | 2 ++ vs2005/hook/hook.vcproj | 2 ++ vs2005/launcher/launcher.vcproj | 4 ++-- vs2005/libsynergy/libsynergy.vcproj | 4 ++-- vs2005/server/server.vcproj | 2 ++ vs2008/hook/hook.vcproj | 2 +- vs2008/launcher/launcher.vcproj | 12 ++++++++++-- vs2008/libsynergy/libsynergy.vcproj | 4 ++-- vs2008/server/server.vcproj | 2 -- 10 files changed, 39 insertions(+), 22 deletions(-) diff --git a/lib/base/CLog.cpp b/lib/base/CLog.cpp index f74db82b..9ebffd3a 100644 --- a/lib/base/CLog.cpp +++ b/lib/base/CLog.cpp @@ -149,9 +149,8 @@ CLog::print(const char* file, int line, const char* fmt, ...) const } // print the prefix to the buffer. leave space for priority label. - char message[2048]; if (file != NULL) { - + char message[2048]; struct tm *tm; char tmp[220]; time_t t; @@ -169,11 +168,12 @@ CLog::print(const char* file, int line, const char* fmt, ...) const message += pPad - g_priorityPad; } */ + // output buffer + output(priority, message); + } else { + output(priority, buffer); } - // output buffer - output(priority, message); - // clean up if (buffer != stack) { delete[] buffer; @@ -272,7 +272,10 @@ CLog::output(int priority, char* msg) const */ // find end of message //char* end = msg + g_priorityPad + strlen(msg + g_priorityPad); - char* end = msg+strlen(msg)-1; + int len = strlen(msg); + char* tmp = new char[len+m_maxNewlineLength+1]; + char* end = tmp + len; + strcpy(tmp, msg); // write to each outputter CArchMutexLock lock(m_mutex); @@ -281,13 +284,13 @@ CLog::output(int priority, char* msg) const ++index) { // get outputter ILogOutputter* outputter = *index; - - // put an appropriate newline at the end - strcpy(end, outputter->getNewline()); + + // put an appropriate newline at the end + strcpy(end, outputter->getNewline()); // write message outputter->write(static_cast(priority), - msg /*+ g_maxPriorityLength - n*/); + tmp /*+ g_maxPriorityLength - n*/); } for (COutputterList::const_iterator index = m_outputters.begin(); index != m_outputters.end(); ++index) { @@ -299,8 +302,10 @@ CLog::output(int priority, char* msg) const // write message and break out of loop if it returns false if (!outputter->write(static_cast(priority), - msg /*+ g_maxPriorityLength - n*/)) { + tmp /*+ g_maxPriorityLength - n*/)) { break; } } + + delete[] tmp; } diff --git a/vs2005/client/client.vcproj b/vs2005/client/client.vcproj index 7c43fe9a..02e7ea35 100644 --- a/vs2005/client/client.vcproj +++ b/vs2005/client/client.vcproj @@ -40,6 +40,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\..\lib\arch;..\..\lib\base;..\..\lib\client;..\..\lib\common;..\..\lib\io;..\..\lib\mt;..\..\lib\net;..\..\lib\platform;..\..\lib\server;..\..\lib\synergy" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -113,6 +114,7 @@ + +