Re: [MERGE] debugs message improvement: use HERE macro wherever sensible

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Mon, 05 Nov 2012 12:35:44 -0700

On 11/05/2012 08:47 AM, Kinkie wrote:
> On Mon, Nov 5, 2012 at 4:19 PM, Alex Rousskov wrote:
>> Long-term, we should consider making HERE in debugs() at level 2 or
>> higher an automatic/default behavior. This will require some work, but I
>> think it is possible, and I think it can even accommodate existing
>> debugs() statements (with or without HERE) _without_ changing them.

> It's hairy at best, if it can even be done, as it depends on cpp
> predefined macro magic (__LINE__, __FILE__ etc).

We already use that magic unconditionally so I do not see us growing
more hairs. It think it will actually be rather simple, something along
these lines:

> #define debugs(SECTION, LEVEL, CONTENT) \
> do { \
> if ((Debug::level = (LEVEL)) <= Debug::Levels[SECTION]) { \
> - Debug::getDebugOut() << CONTENT; \
> + Debug::getDebugOut(__FILE__, __LINE__, __FUNCTION__) << CONTENT; \
> Debug::finishDebug(); \
> } \
> } while (/*CONSTCOND*/ 0)

with an addition to #defining HERE to log nothing and fixing cases where
HERE is used with debug level 1 or lower (those cases should use MYNAME
instead of HERE AFAICT).

The updated Debug::getDebugOut() method will log current code location
if and only if Debug::level exceeds 1.

HTH,

Alex.
Received on Mon Nov 05 2012 - 19:35:47 MST

This archive was generated by hypermail 2.2.0 : Tue Nov 06 2012 - 12:00:04 MST