Uploaded image for project: 'Log4cxx'
  1. Log4cxx
  2. LOGCXX-515

Add macros to utilize libfmt formatting for messages

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 0.12.0
    • None
    • None

    Description

      Create macros that use fmt::format to create the log message.

       

      The prototype looks like this:

      #define LOG4CXX_INFO_FMT(logger, ...) do { \
      		if (logger->isInfoEnabled()) {\
      			logger->forcedLog(::log4cxx::Level::getInfo(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
      

      Usage:

      LOG4CXX_INFO_FMT( logger, "This is a message that has some kind of {} information in it", "useful" );
      

      This is slightly faster at runtime than using the MessageBuffer class with operator<< all the time, and much clearer.  Conveniently, the coloring provided by libfmt also shows up on the output.

       

      is there a better name than LOG4CXX_INFO_FMT?

      Attachments

        Activity

          People

            rmiddleton Robert Middleton
            rmiddleton Robert Middleton
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: