Recently, I’ve found something interesting in Visual Studio that improved my Logger!

I had a function called AddMsg

/** appends message to the log file */ 
void AddMsg(LOG_MODE m, int level, char* strModule, char *strMsg, ...); 

But, when you wanted to add a comment you needed to use quite complicated and long syntnax, like:

/** one need to pass function name... quite boring task */ 
gLogger->AddMsg(lmNormal, 0, "class::func", "bla... param = %d", param); 
// gLogger is a singleton...

But, there is a very useful define in Visual Studio, called __FUNCTION__ that returns name of a current function. So one can use it to automate passing function name to the logMsg function. To do that, I needed to define macro:

#define LOG(m, l, ...) gLogger->AddMsg(m, l, __FUNCTION__, __VA_ARGS__) 

And now one can simply write:

LOG(lmNormal, "bla bla bla... param = %d", param); 

In that way logging becomes a bit more simple…

Some more info