J
jcktmp
I currently have a macro for logging with a definition similar to the
following:
#define LOG shouldLog() && logStream
so that statements of this type may be written:
LOG << "some logging << endl;
I would like to add a static variable to this macro, so that the macro
expands to:
static LogObject x; x.shouldLog() && logStream
The problem is that with control statements that optionally use braces
(if, while, etc.), the multi statement approach doesn't work. Is there
any way to rewrite this (without adding a brace to the log macro and
creating an END macro) so that everything can be done in LOG?
Thanks,
J
following:
#define LOG shouldLog() && logStream
so that statements of this type may be written:
LOG << "some logging << endl;
I would like to add a static variable to this macro, so that the macro
expands to:
static LogObject x; x.shouldLog() && logStream
The problem is that with control statements that optionally use braces
(if, while, etc.), the multi statement approach doesn't work. Is there
any way to rewrite this (without adding a brace to the log macro and
creating an END macro) so that everything can be done in LOG?
Thanks,
J