- Detailed logging question
- Posted by Angus on September 26th, 2007
I want to setup a macro to log informational strings if eg INFOLOGGING
is defined. So I created a macro which outputs informational strings
to a log file.
I want to have a #define which switches this option on or off.
My problem is that I need to do a load of string processing to build
up the informational string. Then the informational string is passed
to the macro. Now if the define is not set then the macro never gets
called. That is fine. But ideally I don't want all this string
processing if the define is not set.
Is my only way round this to have loads of #ifdef <whatever>'s? It
just looks a bit dirty. But I can't see any way round it?
I am trying to implement detailed logging. Errors are always logged
but I want a #define to switch on a higher level of logging.
Anyone got any bright ideas on how to handle this?
- Posted by Jeffrey Adler on September 27th, 2007
"Angus" <anguscomber@gmail.com> wrote in message
news:1190824054.696041.136040@r29g2000hsg.googlegr oups.com...
Something we have done in the past is:
void my_log_msg1 (char *msg)
....
void my_log_msg2 (char *msg, int parm1)
....
etc.
Then,
#ifdef DEBUG
#define log_msg1(x) my_log_msg1(x,y)
#define log_msg2(x,y) my_log_msg2(x,y)
#else
#define log_msg1(x)
#define log_msg2(x,y)
#endif
If DEBUG is defined, lots of code is generated. If debug is not defined, no
code is generated for the log_msg(x) statements.
Or something like that....
HTH
- logging question (Microsoft Windows) by Debbie Graham
- Logging in question (Virus & Worms) by wunnuy@netzero.net
- Detailed question, probably a simple answer - Windows XP (Computers & Technology) by Mike
- PIX VPN logging question (Routers) by Iain Smith
- Detailed Question - Finereadrer 6.0 vs. Omnipage 12 (Scanners) by Daniel Thompson

