Re: __FUNCTION__ and debug.

From: Robert Collins <robertc@dont-contact.us>
Date: 28 Oct 2002 09:08:03 +1100

On Mon, 2002-10-28 at 04:09, Henrik Nordstrom wrote:
> On Sunday 27 October 2002 05.02, Adrian Chadd wrote:

> I am all for the principle of automatically emitting which function
> the debug trace is from, but agree with Adrian that the trace() name
> is perhaps a bit ambigious.
>
> Why not simply let it be debug() and gradually clean up the debug
> statements who manually emits a function name to not do so..?

because debug is a define, and defines can't be overloaded,only
replaced. debug_printf or something like that is ok.
 
> What I don't quite get is a minor syntactic thing in how you convince
> the compiler to add __FUNCTION__ to the format string with the
> proposed syntax, but I guess it is all possible with some OO
> trickery..

It's just some #define trickery actually. see defines.h in the
fix_ranges branch patch, where I've played with this.

> It might need a sister who writes raw information to the debug log,
> i.e.
>
> debug_raw(section, level)(format, ...)
>
> which sends the data (if below the fence) as is to the debug log, not
> even a timestamp I think.

Hmm, ideas happening here. I think if we rework the existing debug() a
little, I can make _db_print simpler, and use it in the trace() (or
whatever it gets called) too.

Oh, trace() an debug() need to stay macros, as debug expands to:
[if (level > debug_level[section])
  void 0;
else
  _db_print]("log message");
The square brackets are the macro limits.

Trace behaves similarly, although I've made it be trace (section, level,
"format", ....); which is aesthetically more pleasing for me.

Rob

Received on Sun Oct 27 2002 - 15:08:08 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:17:01 MST