No subject
59452-JH BuehlerBLU123
jhpb at granjon.ATT.COM
Sat May 5 04:13:40 AEST 1990
I usually use a varargs routine, which in turn uses vsprintf(). This
lets me put what arguments in I like, and gets rid of the double
parentheses required in the #define solutions for similar functionality.
To get rid of the function calls when they're not needed, you can use
the #define trick and let the compiler optimize the function calls out.
e.g.,
#ifdef DEBUG
# define LOG log
#else
# define LOG if (0) log
#endif
LOG(level, "example %d", 1);
The log() I use puts in a time stamp, the process id, makes funny
characters visible, and writes it to a log file that gets renamed
elsewhere when the ulimit is hit.
Joe Buehler
More information about the Comp.lang.c
mailing list