Is there a better way than #if DebugMode for logging
Posted
by Daniel
on Stack Overflow
See other posts from Stack Overflow
or by Daniel
Published on 2010-04-15T04:50:46Z
Indexed on
2010/04/15
4:53 UTC
Read the original article
Hit count: 293
I'm making a c++ library thats going to be P/Invoked from c#, so i am unable to breakpoint/debug the c++ side of things. So i decided to add logging so i can see if anything goes wrong and where it happens. I add a #define DebugMode 1
in order to determine if i am to log or not.
First of all i'm not very good at c++ but i know enough to get around. So my questions are:
Is there a better way than wrapping
#if DebugMode #endif
s around every Log call? I could simply do that inside the method and just return if logging isn't disabled but won't that mean then all those logging strings will be in the assembly?How can i emulate what printf does with its "..." operator enabling me to pass something like
Log("Variable x is {0}", x);
Thanks!
© Stack Overflow or respective owner