Skip to content
Snippets Groups Projects
Commit 4485e0a0 authored by Marcel Loose's avatar Marcel Loose :sunglasses:
Browse files

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.
parent cfe11068
No related branches found
No related tags found
No related merge requests found
...@@ -249,20 +249,18 @@ namespace LOFAR { ...@@ -249,20 +249,18 @@ namespace LOFAR {
// Create a TraceLogger object that will output your message during construct // Create a TraceLogger object that will output your message during construct
// and destruction. Your message is preceeded with "ENTER:" or "EXIT:". // 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::LifetimeLogger _tmpLifetimeTraceObj(level, getLogger().logger(), \
::LOFAR::formatString("%s:%s", AUTO_FUNCTION_NAME, message), \ ::LOFAR::formatString("%s:%s", AUTO_FUNCTION_NAME, message), \
__FILE__, __LINE__); \ __FILE__, __LINE__);
} while(0)
// Create a TraceLogger object that will output your message during construct // Create a TraceLogger object that will output your message during construct
// and destruction. Your message is preceeded with "ENTER:" or "EXIT:". // 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; \ std::ostringstream oss; \
oss << AUTO_FUNCTION_NAME << ":" << stream; \ oss << AUTO_FUNCTION_NAME << ":" << stream; \
::LOFAR::LifetimeLogger _tmpLifetimeTraceObj(level, getLogger().logger(), \ ::LOFAR::LifetimeLogger _tmpLifetimeTraceObj(level, getLogger().logger(), \
oss.str(), __FILE__, __LINE__); \ oss.str(), __FILE__, __LINE__);
} while(0)
//# ----------- implementation details tracer part ------------- //# ----------- implementation details tracer part -------------
......
...@@ -136,14 +136,13 @@ public: \ ...@@ -136,14 +136,13 @@ public: \
//# //#
//# LOG_TRACE_LIFETIME(_STR) (level, message|stream) //# 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) ) { \ if( LFDebugCheck(level) ) { \
::LOFAR::LFDebug::Tracer objname; \ ::LOFAR::LFDebug::Tracer objname; \
constructStream(stream); \ constructStream(stream); \
objname.startMsg (LOG4CPLUS_LEVEL(level), __FILE__, __LINE__, \ objname.startMsg (LOG4CPLUS_LEVEL(level), __FILE__, __LINE__, \
AUTO_FUNCTION_NAME, oss.str().c_str(), 0); \ AUTO_FUNCTION_NAME, oss.str().c_str(), 0); \
} \ }
} while(0)
#define LOG_TRACE_LIFETIME(level,message) \ #define LOG_TRACE_LIFETIME(level,message) \
LOG_TRACE_LIFETIME_STR(level, message) LOG_TRACE_LIFETIME_STR(level, message)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment