
Mark Blewett wrote:
I think it's the wrong approach. In our company we have implemented logging through macros which has one very important property: When I write
LOG_DEBUG( whatever() );
into my source, then whatever() is only evaluated when the debug-logger is active. The macro basically expands to something like this:
if( Base::hasLogger( LogLevel::DEBUG ) ) Base::log( whatever(), LogLevel::DEBUG );
I think this cannot be done without macros as normal function calls (including operator<< for streams) need to evaluate their arguments before they are called. As the difference in the application execution speed can vary by a factor of 1000, this is a very valuable optimization for us. My 2¢.
Personally I think restricting boost to disabling logging on a #define is a double negative... ie a no no.
You misread what I wrote. Logging is disabled through the return value of hasLogger(), which can be modified at any time. When hasLogger() returns false, the expression whatever() is never evaluated, which is the important part. The macro never removes the code itself (well, it could, but we never needed it so far). Regards, Daniel -- Daniel Frey aixigo AG - financial solutions & technology Schloß-Rahe-Straße 15, 52072 Aachen, Germany fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99 eMail: daniel.frey@aixigo.de, web: http://www.aixigo.de