From 4485e0a0ea484db3a94e2e32aff0da410e41fe57 Mon Sep 17 00:00:00 2001 From: Marcel Loose <loose@astron.nl> Date: Thu, 8 Jun 2006 07:19:03 +0000 Subject: [PATCH] BugID: 670 I was overzealous by tunrning the LOG_TRACE_LIFETIME(_STR) macros into real statements using a do {...} while(0) construct. This caused the lifetime tracer to be destroyed at the end of the do-while loop, instead of at the end of the enclosing loop. --- LCS/Common/include/Common/LofarLog4Cplus.h | 10 ++++------ LCS/Common/include/Common/LofarLogCout.h | 5 ++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/LCS/Common/include/Common/LofarLog4Cplus.h b/LCS/Common/include/Common/LofarLog4Cplus.h index e27580f7378..0d8b4a97cba 100644 --- a/LCS/Common/include/Common/LofarLog4Cplus.h +++ b/LCS/Common/include/Common/LofarLog4Cplus.h @@ -249,20 +249,18 @@ namespace LOFAR { // Create a TraceLogger object that will output your message during construct // and destruction. Your message is preceeded with "ENTER:" or "EXIT:". -#define LOG_TRACE_LIFETIME(level,message) do { \ +#define LOG_TRACE_LIFETIME(level,message) \ ::LOFAR::LifetimeLogger _tmpLifetimeTraceObj(level, getLogger().logger(), \ ::LOFAR::formatString("%s:%s", AUTO_FUNCTION_NAME, message), \ - __FILE__, __LINE__); \ - } while(0) + __FILE__, __LINE__); // Create a TraceLogger object that will output your message during construct // and destruction. Your message is preceeded with "ENTER:" or "EXIT:". -#define LOG_TRACE_LIFETIME_STR(level,stream) do { \ +#define LOG_TRACE_LIFETIME_STR(level,stream) \ std::ostringstream oss; \ oss << AUTO_FUNCTION_NAME << ":" << stream; \ ::LOFAR::LifetimeLogger _tmpLifetimeTraceObj(level, getLogger().logger(), \ - oss.str(), __FILE__, __LINE__); \ - } while(0) + oss.str(), __FILE__, __LINE__); //# ----------- implementation details tracer part ------------- diff --git a/LCS/Common/include/Common/LofarLogCout.h b/LCS/Common/include/Common/LofarLogCout.h index c4f44d93d11..48e3924b313 100644 --- a/LCS/Common/include/Common/LofarLogCout.h +++ b/LCS/Common/include/Common/LofarLogCout.h @@ -136,14 +136,13 @@ public: \ //# //# LOG_TRACE_LIFETIME(_STR) (level, message|stream) //# -#define LOG_TRACE_LIFETIME_STR(level, stream) do { \ +#define LOG_TRACE_LIFETIME_STR(level, stream) \ if( LFDebugCheck(level) ) { \ ::LOFAR::LFDebug::Tracer objname; \ constructStream(stream); \ objname.startMsg (LOG4CPLUS_LEVEL(level), __FILE__, __LINE__, \ AUTO_FUNCTION_NAME, oss.str().c_str(), 0); \ - } \ - } while(0) + } #define LOG_TRACE_LIFETIME(level,message) \ LOG_TRACE_LIFETIME_STR(level, message) -- GitLab