Guten Tag Matthew Bingham,
am Freitag, 7. Januar 2011 um 14:02 schrieben Sie:
> I know one way is to use std::stringstream, set its precision, build the
> string myself, then pass it into log4cxx. However, I am concerned about
> performance and would hate to build the string only for it not to be logged
> because it is only a DEBUG log and need atleast INFO to log.
Performance should not be an issue if you use a function, class or
something and use it directly in the macro. It only gets executed if
the level fits.
LOG4CXX_DEBUG(logger_, "value is " << buildHighPrecStringForLogging(tmp));
Depends if I understood the following right, of course. ;-)
#define LOG4CXX_DEBUG(logger, message) { \
if (LOG4CXX_UNLIKELY(logger->isDebugEnabled())) {\
::log4cxx::helpers::MessageBuffer oss_; \
logger->forcedLog(::log4cxx::Level::getDebug(), oss_.str(oss_ <<
message), LOG4CXX_LOCATION); }}
#else
#define LOG4CXX_DEBUG(logger, message)
#endif
Mit freundlichen Grüßen,
Thorsten Schöning
--
Thorsten Schöning
AM-SoFT IT-Systeme - Hameln | Potsdam | Leipzig
Telefon: Potsdam: 0331-743881-0
E-Mail: [email protected]
Web: http://www.am-soft.de
AM-SoFT GmbH IT-Systeme, Konsumhof 1-5, 14482 Potsdam
Amtsgericht Potsdam HRB 21278 P, Geschäftsführer: Andreas Muchow