On 21 Dec '06, at 6:37 AM, Daniel Stenberg wrote:

I want to modify libssh2 to always build with debug output ability when it is built with ./configure --enable-debug, and just provide a function to switch on/off the different outputs that currently are controlled with #ifdefs.

Good idea. I always do something similar in projects I write. I use a logging macro like this:

#ifdef LOGGING_ENABLED
        extern bool gLogging;
#else
        #define gLogging false
#endif

#define Log  if( !gLogging ) ; else printf

This gives you a Log() macro you call just like printf. If at compile- time you define LOGGING_ENABLED, then at runtime you can turn it on or off by setting the variable gLogging. When gLogging is off, there is nearly zero runtime overhead (just testing a global and jumping over the printf call.) And in a production build if you don't define LOGGING_ENABLED, the log calls don't get compiled at all.

--Jens
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
libssh2-devel mailing list
libssh2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel

Reply via email to