On 11/05/2012 01:48 PM, Kinkie wrote:

>   IIRC that's exactly the problem: __FILE__ is always Debug.h there

If that were true, our existing HERE macro would not work either.


http://stackoverflow.com/questions/5047597/file-in-h-what-does-it-resolve-to


HTH,

Alex.



> On Nov 5, 2012 8:35 PM, "Alex Rousskov"
> <[email protected]
> <mailto:[email protected]>> wrote:
> 
>     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.
> 

Reply via email to