Log prefix has to be updated per call after all

This commit is contained in:
PatrickvL 2016-12-23 17:06:17 +01:00
parent 16f7356103
commit 67cf33b928
2 changed files with 3 additions and 9 deletions

View File

@ -35,7 +35,5 @@
#include "Logging.h" #include "Logging.h"
// For thread_local, see : http://en.cppreference.com/w/cpp/language/storage_duration // For thread_local, see : http://en.cppreference.com/w/cpp/language/storage_duration
thread_local const DWORD _CurrentThreadId = GetCurrentThreadId();
// TODO : Use Boost.Format http://www.boost.org/doc/libs/1_53_0/libs/format/index.html // TODO : Use Boost.Format http://www.boost.org/doc/libs/1_53_0/libs/format/index.html
thread_local std::string _logPrefix; thread_local std::string _logPrefix;

View File

@ -139,8 +139,6 @@ inline const char * _log_sanitize(BOOLEAN value) { return value ? "TRUE" : "FALS
// //
// For thread_local, see : http://en.cppreference.com/w/cpp/language/storage_duration // For thread_local, see : http://en.cppreference.com/w/cpp/language/storage_duration
extern thread_local const DWORD _CurrentThreadId;
// TODO : Use Boost.Format http://www.boost.org/doc/libs/1_53_0/libs/format/index.html // TODO : Use Boost.Format http://www.boost.org/doc/libs/1_53_0/libs/format/index.html
extern thread_local std::string _logPrefix; extern thread_local std::string _logPrefix;
@ -148,11 +146,9 @@ extern thread_local std::string _logPrefix;
#define LOG_FUNC_BEGIN \ #define LOG_FUNC_BEGIN \
do { if(g_bPrintfOn) { \ do { if(g_bPrintfOn) { \
bool _had_arg = false; \ bool _had_arg = false; \
if (_logPrefix.empty()) { \
std::stringstream tmp; \ std::stringstream tmp; \
tmp << __FILENAME__ << " (" << hex2((uint16_t)_CurrentThreadId) << "): "; \ tmp << __FILENAME__ << " (" << hex2((uint16_t)GetCurrentThreadId()) << "): "; \
_logPrefix = tmp.str(); \ _logPrefix = tmp.str(); \
}; \
std::stringstream msg; \ std::stringstream msg; \
msg << _logPrefix << __func__ << "("; msg << _logPrefix << __func__ << "(";