libmoost
/home/mhx/git/github/libmoost/include/moost/logging/logger.hpp File Reference
#include <string>
#include <stdexcept>
#include <log4cxx/logger.h>
#include <boost/preprocessor/stringize.hpp>
#include "global.hpp"
Include dependency graph for logger.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  moost
 

Creates a unique temporary directory; removed on scope exit.


namespace  moost::logging

Defines

#define MLOG_PREFIX__(msg)   msg
 Log message prefix.
#define MLOG_LEVEL_TRACE   LOG4CXX_TRACE
 Loggin macros.
#define MLOG_LEVEL_DEBUG   LOG4CXX_DEBUG
#define MLOG_LEVEL_INFO   LOG4CXX_INFO
#define MLOG_LEVEL_WARN   LOG4CXX_WARN
#define MLOG_LEVEL_ERROR   LOG4CXX_ERROR
#define MLOG_LEVEL_FATAL   LOG4CXX_FATAL
#define MLOG(level, logger, msg)   level(logger, MLOG_PREFIX__(msg));
 Logging macro.
#define MLOG_TRACE(logger, msg)   MLOG(MLOG_LEVEL_TRACE, logger, msg)
#define MLOG_DEBUG(logger, msg)   MLOG(MLOG_LEVEL_DEBUG, logger, msg)
#define MLOG_INFO(logger, msg)   MLOG(MLOG_LEVEL_INFO, logger, msg)
#define MLOG_WARN(logger, msg)   MLOG(MLOG_LEVEL_WARN, logger, msg)
#define MLOG_ERROR(logger, msg)   MLOG(MLOG_LEVEL_ERROR, logger, msg)
#define MLOG_FATAL(logger, msg)   MLOG(MLOG_LEVEL_FATAL, logger, msg)
#define MLOG_NAMED_LOGGER(name)   log4cxx::Logger::getLogger(name)
 Gets a named logger.
#define MLOG_DEFAULT_LOGGER()   log4cxx::Logger::getRootLogger()
 Gets an anonymous logger.
#define MLOG_NAMED_DEFINE(logger, name)   log4cxx::LoggerPtr logger = MLOG_NAMED_LOGGER(name)
 Creates a named logger type.
#define MLOG_NAMED(level, name, msg)   MLOG(level, MLOG_NAMED_LOGGER(name), msg)
 Log to a named logger.
#define MLOG_NAMED_TRACE(name, msg)   MLOG_NAMED(MLOG_LEVEL_TRACE, name, msg)
#define MLOG_NAMED_DEBUG(name, msg)   MLOG_NAMED(MLOG_LEVEL_DEBUG, name, msg)
#define MLOG_NAMED_INFO(name, msg)   MLOG_NAMED(MLOG_LEVEL_INFO, name, msg)
#define MLOG_NAMED_WARN(name, msg)   MLOG_NAMED(MLOG_LEVEL_WARN, name, msg)
#define MLOG_NAMED_ERROR(name, msg)   MLOG_NAMED(MLOG_LEVEL_ERROR, name, msg)
#define MLOG_NAMED_FATAL(name, msg)   MLOG_NAMED(MLOG_LEVEL_FATAL, name, msg)
#define MLOG_DEFAULT_DEFINE(logger)   logger = MLOG_DEFAULT_LOGGER()
 Creates a default logger type.
#define MLOG_DEFAULT(level, msg)   MLOG(level, MLOG_DEFAULT_LOGGER(), msg)
 Default logger.
#define MLOG_DEFAULT_TRACE(msg)   MLOG_DEFAULT(MLOG_LEVEL_TRACE, msg)
#define MLOG_DEFAULT_DEBUG(msg)   MLOG_DEFAULT(MLOG_LEVEL_DEBUG, msg)
#define MLOG_DEFAULT_INFO(msg)   MLOG_DEFAULT(MLOG_LEVEL_INFO, msg)
#define MLOG_DEFAULT_WARN(msg)   MLOG_DEFAULT(MLOG_LEVEL_WARN, msg)
#define MLOG_DEFAULT_ERROR(msg)   MLOG_DEFAULT(MLOG_LEVEL_ERROR, msg)
#define MLOG_DEFAULT_FATAL(msg)   MLOG_DEFAULT(MLOG_LEVEL_FATAL, msg)
#define MLOG_ASSERT(cond, logger, msg)
 Logging macro for asserts.
#define MLOG_NAMED_ASSERT(cond, name, msg)   MLOG_ASSERT(cond, MLOG_NAMED_LOGGER(name), msg)
 Named logging macro for asserts.
#define MLOG_DEFAULT_ASSERT(cond, msg)   MLOG_ASSERT(cond, MLOG_DEFAULT_LOGGER(), msg)
 Default logging macro for asserts.
#define MLOG_TEST(level, cond, logger, msg)   if(!(cond)) MLOG(level, logger, msg);
 Logging macro for logging false predicate results.
#define MLOG_NAMED_TEST(level, cond, name, msg)   MLOG(level, cond, MLOG_NAMED_LOGGER(name), msg)
 Named logging macro for logging false predicate results.
#define MLOG_DEFAULT_TEST(level, cond, msg)   MLOG(level, cond, MLOG_DEFAULT_LOGGER(), msg)
 Default logging macro for logging false predicate results.
#define MLOG_TEST_TRACE(cond, logger, msg)   MLOG_TEST(MLOG_LEVEL_TRACE, cond, logger, msg)
#define MLOG_TEST_DEBUG(cond, logger, msg)   MLOG_TEST(MLOG_LEVEL_DEBUG, cond, logger, msg)
#define MLOG_TEST_INFO(cond, logger, msg)   MLOG_TEST(MLOG_LEVEL_INFO, cond, logger, msg)
#define MLOG_TEST_WARN(cond, logger, msg)   MLOG_TEST(MLOG_LEVEL_WARN, cond, logger, msg)
#define MLOG_TEST_ERROR(cond, logger, msg)   MLOG_TEST(MLOG_LEVEL_ERROR, cond, logger, msg)
#define MLOG_TEST_FATAL(cond, logger, msg)   MLOG_TEST(MLOG_LEVEL_FATAL, cond, logger, msg)
#define MLOG_NAMED_TEST_TRACE(cond, name, msg)   MLOG_DEFAULT_TEST(MLOG_LEVEL_TRACE, cond, name, msg)
#define MLOG_NAMED_TEST_DEBUG(cond, name, msg)   MLOG_DEFAULT_TEST(MLOG_LEVEL_DEBUG, cond, name, msg)
#define MLOG_NAMED_TEST_INFO(cond, name, msg)   MLOG_DEFAULT_TEST(MLOG_LEVEL_INFO, cond, name, msg)
#define MLOG_NAMED_TEST_WARN(cond, name, msg)   MLOG_DEFAULT_TEST(MLOG_LEVEL_WARN, cond, name, msg)
#define MLOG_NAMED_TEST_ERROR(cond, name, msg)   MLOG_DEFAULT_TEST(MLOG_LEVEL_ERROR, cond, name, msg)
#define MLOG_NAMED_TEST_FATAL(cond, name, msg)   MLOG_DEFAULT_TEST(MLOG_LEVEL_FATAL, cond, name, msg)
#define MLOG_DEFAULT_TEST_TRACE(cond, msg)   MLOG_DEFAULT_TEST(MLOG_LEVEL_TRACE, cond, msg)
#define MLOG_DEFAULT_TEST_DEBUG(cond, msg)   MLOG_DEFAULT_TEST(MLOG_LEVEL_DEBUG, cond, msg)
#define MLOG_DEFAULT_TEST_INFO(cond, msg)   MLOG_DEFAULT_TEST(MLOG_LEVEL_INFO, cond, msg)
#define MLOG_DEFAULT_TEST_WARN(cond, msg)   MLOG_DEFAULT_TEST(MLOG_LEVEL_WARN, cond, msg)
#define MLOG_DEFAULT_TEST_ERROR(cond, msg)   MLOG_DEFAULT_TEST(MLOG_LEVEL_ERROR, cond, msg)
#define MLOG_DEFAULT_TEST_FATAL(cond, msg)   MLOG_DEFAULT_TEST(MLOG_LEVEL_FATAL, cond, msg)
#define MLOG_CHECK(cond, logger, msg)   MLOG_TEST_ERROR(cond, logger, msg)
 Logging macro for checking predicate results.
#define MLOG_NAMED_CHECK(cond, name, msg)   MLOG_CHECK(cond, MLOG_NAMED_LOGGER(name), msg)
 Named logging macro for checking predicate predicate results.
#define MLOG_DEFAULT_CHECK(cond, msg)   MLOG_CHECK(cond, MLOG_DEFAULT_LOGGER(), msg)
 Default logging macro for checking false predicate results.
#define MLOG_THROW(cond, logger, msg)
 Logging macro for checking predicate results.
#define MLOG_THROW_IF(cond, logger, msg)
 Macro to either throw or log an error.
#define MLOG_NAMED_THROW(cond, name, msg)   MLOG_THROW(cond, MLOG_NAMED_LOGGER(name), msg)
 Named logging macro for checking predicate predicate results.
#define MLOG_NAMED_THROW_IF(cond, name, msg)   MLOG_THROW_IF(cond, MLOG_NAMED_LOGGER(name), msg)
 Named macro to either throw or log an error.
#define MLOG_DEFAULT_THROW(cond, msg)   MLOG_THROW(cond, MLOG_DEFAULT_LOGGER(), msg)
 Default logging macro for checking false predicate results.
#define MLOG_DEFAULT_THROW_IF(cond, msg)   MLOG_THROW_IF(cond, MLOG_DEFAULT_LOGGER(), msg)
 Default macro to either throw or log an error.
#define MLOG_VERIFY(cond, logger, msg)
 Logging macro for checking predicate results.
#define MLOG_NAMED_VERIFY(cond, name, msg)   MLOG_VERIFY(cond, MLOG_NAMED_LOGGER(name), msg)
 Named logging macro for checking predicate predicate results.
#define MLOG_DEFAULT_VERIFY(cond, msg)   MLOG_VERIFY(cond, MLOG_DEFAULT_LOGGER(), msg)
 Default logging macro for checking false predicate results.
#define MLOG_GET_LEVEL_ALL   log4cxx::Level::getAll()
 Get logging level objects.
#define MLOG_GET_LEVEL_OFF   log4cxx::Level::getOff()
#define MLOG_GET_LEVEL_TRACE   log4cxx::Level::getTrace()
#define MLOG_GET_LEVEL_DEBUG   log4cxx::Level::getDebug()
#define MLOG_GET_LEVEL_INFO   log4cxx::Level::getInfo()
#define MLOG_GET_LEVEL_WARN   log4cxx::Level::getWarn()
#define MLOG_GET_LEVEL_ERROR   log4cxx::Level::getError()
#define MLOG_GET_LEVEL_FATAL   log4cxx::Level::getFatal()
#define MLOG_SET_LEVEL(level, logger)   logger->setLevel(level);
 Programatically set the level of a logger.
#define MLOG_SET_NAMED_LEVEL(level, name)   MLOG_SET_LEVEL(level, MLOG_NAMED_LOGGER(name))
 Programatically set the level of a named logger.
#define MLOG_SET_DEFAULT_LEVEL(level)   MLOG_SET_LEVEL(level, MLOG_DEFAULT_LOGGER())
 Programatically set the level of the default (root) logger.
#define MLOG_SET_LEVEL_ALL(logger)   MLOG_SET_LEVEL(MLOG_GET_LEVEL_ALL, logger)
#define MLOG_SET_LEVEL_OFF(logger)   MLOG_SET_LEVEL(MLOG_GET_LEVEL_OFF, logger)
#define MLOG_SET_LEVEL_TRACE(logger)   MLOG_SET_LEVEL(MLOG_GET_LEVEL_TRACE, logger)
#define MLOG_SET_LEVEL_DEBUG(logger)   MLOG_SET_LEVEL(MLOG_GET_LEVEL_DEBUG, logger)
#define MLOG_SET_LEVEL_INFO(logger)   MLOG_SET_LEVEL(MLOG_GET_LEVEL_INFO, logger)
#define MLOG_SET_LEVEL_WARN(logger)   MLOG_SET_LEVEL(MLOG_GET_LEVEL_WARN, logger)
#define MLOG_SET_LEVEL_ERROR(logger)   MLOG_SET_LEVEL(MLOG_GET_LEVEL_ERROR, logger)
#define MLOG_SET_LEVEL_FATAL(logger)   MLOG_SET_LEVEL(MLOG_GET_LEVEL_FATAL, logger)
#define MLOG_SET_NAMED_LEVEL_ALL(name)   MLOG_SET_LEVEL(MLOG_GET_LEVEL_ALL, MLOG_NAMED_LOGGER(name))
#define MLOG_SET_NAMED_LEVEL_OFF(name)   MLOG_SET_LEVEL(MLOG_GET_LEVEL_OFF, MLOG_NAMED_LOGGER(name))
#define MLOG_SET_NAMED_LEVEL_TRACE(name)   MLOG_SET_LEVEL(MLOG_GET_LEVEL_TRACE, MLOG_NAMED_LOGGER(name))
#define MLOG_SET_NAMED_LEVEL_DEBUG(name)   MLOG_SET_LEVEL(MLOG_GET_LEVEL_DEBUG, MLOG_NAMED_LOGGER(name))
#define MLOG_SET_NAMED_LEVEL_INFO(name)   MLOG_SET_LEVEL(MLOG_GET_LEVEL_INFO, MLOG_NAMED_LOGGER(name))
#define MLOG_SET_NAMED_LEVEL_WARN(name)   MLOG_SET_LEVEL(MLOG_GET_LEVEL_WARN, MLOG_NAMED_LOGGER(name))
#define MLOG_SET_NAMED_LEVEL_ERROR(name)   MLOG_SET_LEVEL(MLOG_GET_LEVEL_ERROR, MLOG_NAMED_LOGGER(name))
#define MLOG_SET_NAMED_LEVEL_FATAL(name)   MLOG_SET_LEVEL(MLOG_GET_LEVEL_FATAL, MLOG_NAMED_LOGGER(name))
#define MLOG_SET_DEFAULT_LEVEL_ALL()   MLOG_SET_LEVEL(MLOG_GET_LEVEL_ALL, MLOG_DEFAULT_LOGGER())
#define MLOG_SET_DEFAULT_LEVEL_OFF()   MLOG_SET_LEVEL(MLOG_GET_LEVEL_OFF, MLOG_DEFAULT_LOGGER())
#define MLOG_SET_DEFAULT_LEVEL_TRACE()   MLOG_SET_LEVEL(MLOG_GET_LEVEL_TRACE, MLOG_DEFAULT_LOGGER())
#define MLOG_SET_DEFAULT_LEVEL_DEBUG()   MLOG_SET_LEVEL(MLOG_GET_LEVEL_DEBUG, MLOG_DEFAULT_LOGGER())
#define MLOG_SET_DEFAULT_LEVEL_INFO()   MLOG_SET_LEVEL(MLOG_GET_LEVEL_INFO, MLOG_DEFAULT_LOGGER())
#define MLOG_SET_DEFAULT_LEVEL_WARN()   MLOG_SET_LEVEL(MLOG_GET_LEVEL_WARN, MLOG_DEFAULT_LOGGER())
#define MLOG_SET_DEFAULT_LEVEL_ERROR()   MLOG_SET_LEVEL(MLOG_GET_LEVEL_ERROR, MLOG_DEFAULT_LOGGER())
#define MLOG_SET_DEFAULT_LEVEL_FATAL()   MLOG_SET_LEVEL(MLOG_GET_LEVEL_FATAL, MLOG_DEFAULT_LOGGER())
#define MLOG_GET_LEVELSTR_ALL   "all"
 Names of the standard logging levels.
#define MLOG_GET_LEVELSTR_OFF   "off"
#define MLOG_GET_LEVELSTR_TRACE   "trace"
#define MLOG_GET_LEVELSTR_DEBUG   "debug"
#define MLOG_GET_LEVELSTR_INFO   "info"
#define MLOG_GET_LEVELSTR_WARN   "warn"
#define MLOG_GET_LEVELSTR_ERROR   "error"
#define MLOG_GET_LEVELSTR_FATAL   "fatal"
#define MLOG_SET_LEVELSTR(levelstr, logger)   MLOG_SET_LEVEL(moost::logging::str2level(levelstr), logger);
 Programatically set the level of a logger.
#define MLOG_SET_NAMED_LEVELSTR(levelstr, name)   MLOG_SET_LEVELSTR(levelstr, MLOG_NAMED_LOGGER(name))
 Programatically set the level of the default (root) logger.
#define MLOG_SET_DEFAULT_LEVELSTR(levelstr)   MLOG_SET_LEVELSTR(levelstr, MLOG_DEFAULT_LOGGER())

Functions

log4cxx::LevelPtr moost::logging::str2level (std::string const level)

Define Documentation

#define MLOG (   level,
  logger,
  msg 
)    level(logger, MLOG_PREFIX__(msg));

Logging macro.

All logging is performed using this macro. It provides an abstraction from log4cxx and will include the log prefix if one is defined.

Parameters:
[in]level,:The logging level MLOG_LEVEL_[TRACE, DEBUG, INFO, WARN, ERROR and FATAL]
[in]logger,:Logger object
[in]msg,:Stream expression that will be rendered as a message
 MLOG(
    MLOG_LEVEL_DEBUG,
    MLOG_DEFAULT(),
    "some value: " << 0xF4 << ", " << "another value: " << 32.02f
 );

Definition at line 103 of file logger.hpp.

#define MLOG_ASSERT (   cond,
  logger,
  msg 
)
Value:
if(!(cond)) \
   { \
      LOG4CXX_ASSERT(logger, false, MLOG_PREFIX__(msg)); \
      assert(false && "MLOG_ASSERT assertion failure"); \
   }

Logging macro for asserts.

All assert logging is performed using this macro. It provides an abstraction from log4cxx and will allow you to assert an expression and if it's false it will log an error and then generate a runtime assert if NDEBUG is not defined.

Parameters:
[in]cond,:A predicate condition that will be tested
[in]logger,:Logger object
[in]msg,:Stream expression that will be rendered as a message
 MLOG_ASSERT(
    (x == y),
    MLOG_DEFAULT_LOGGER(),
    "Expected x and y to be the same!"
 );

Definition at line 278 of file logger.hpp.

#define MLOG_CHECK (   cond,
  logger,
  msg 
)    MLOG_TEST_ERROR(cond, logger, msg)

Logging macro for checking predicate results.

All check logging is performed using this macro. It provides an abstraction from log4cxx and will allow you to check an expression and if it's false it will log an error.

Parameters:
[in]cond,:A predicate condition that will be tested
[in]logger,:Logger object
[in]msg,:Stream expression that will be rendered as a message
 MLOG_CHECK(
    (x == y),
    MLOG_DEFAULT_LOGGER(),
    "Expected x and y to be the same!"
 );

Definition at line 466 of file logger.hpp.

#define MLOG_DEBUG (   logger,
  msg 
)    MLOG(MLOG_LEVEL_DEBUG, logger, msg)

Definition at line 114 of file logger.hpp.

#define MLOG_DEFAULT (   level,
  msg 
)    MLOG(level, MLOG_DEFAULT_LOGGER(), msg)

Default logger.

Allows logging to an anonymous logger without the need to explicitly create it.

Parameters:
[in]level,:The logging level MLOG_[TRACE, DEBUG, INFO, WARN, ERROR and FATAL]
[in]msg,:Stream expression that will be rendered as a message
 MLOG_DEFAULT(MLOG_LEVEL_DEBUG, "some value: " << 394)

Definition at line 240 of file logger.hpp.

#define MLOG_DEFAULT_ASSERT (   cond,
  msg 
)    MLOG_ASSERT(cond, MLOG_DEFAULT_LOGGER(), msg)

Default logging macro for asserts.

Allows you to assert an expression and if it's false it will log an error to an anonymous logger and then generate a runtime assert if NDEBUG is not defined.

Parameters:
[in]cond,:A predicate condition that will be tested
[in]msg,:Stream expression that will be rendered as a message
 MLOG_DEFAULT_ASSERT(
    (x == y),
    "Expected x and y to be the same!"
 );

Definition at line 326 of file logger.hpp.

#define MLOG_DEFAULT_CHECK (   cond,
  msg 
)    MLOG_CHECK(cond, MLOG_DEFAULT_LOGGER(), msg)

Default logging macro for checking false predicate results.

Allows you to check an expression and if it's false it will log it to an anonymous logger as an error.

Parameters:
[in]cond,:A predicate condition that will be tested
[in]msg,:Stream expression that will be rendered as a message
 MLOG_DEFAULT_CHECK(
    (x == y),
    "Expected x and y to be the same!"
 );

Definition at line 510 of file logger.hpp.

#define MLOG_DEFAULT_DEBUG (   msg)    MLOG_DEFAULT(MLOG_LEVEL_DEBUG, msg)

Definition at line 251 of file logger.hpp.

#define MLOG_DEFAULT_DEFINE (   logger)    logger = MLOG_DEFAULT_LOGGER()

Creates a default logger type.

Note the you'll have no specific granular control over this logger.

Parameters:
[out]logger,:The name of the logger type being created
 MLOG_DEFAULT_DEFINE(my_logger)
 MLOG(MLOG_LEVEL_DEBUG, my_logger, "log this: " << 944534634578UL);

Definition at line 221 of file logger.hpp.

#define MLOG_DEFAULT_ERROR (   msg)    MLOG_DEFAULT(MLOG_LEVEL_ERROR, msg)

Definition at line 254 of file logger.hpp.

#define MLOG_DEFAULT_FATAL (   msg)    MLOG_DEFAULT(MLOG_LEVEL_FATAL, msg)

Definition at line 255 of file logger.hpp.

#define MLOG_DEFAULT_INFO (   msg)    MLOG_DEFAULT(MLOG_LEVEL_INFO, msg)

Definition at line 252 of file logger.hpp.

#define MLOG_DEFAULT_LOGGER ( )    log4cxx::Logger::getRootLogger()

Gets an anonymous logger.

Return an anonymous logger

 MLOG(MLOG_LEVEL_DEBUG,  MLOG_DEFAULT_LOGGER(), "log this: " << 944534634578UL);

Definition at line 150 of file logger.hpp.

#define MLOG_DEFAULT_TEST (   level,
  cond,
  msg 
)    MLOG(level, cond, MLOG_DEFAULT_LOGGER(), msg)

Default logging macro for logging false predicate results.

Allows you to test an expression and if it's false it will log it to an anonymous logger at the desired level.

Parameters:
[in]level,:The logging level MLOG_[TRACE, DEBUG, INFO, WARN, ERROR and FATAL]
[in]cond,:A predicate condition that will be tested
[in]msg,:Stream expression that will be rendered as a message
 MLOG_DEFAULT_TEST(
    MLOG_LEVEL_DEBUG
    (x == y),
    "Expected x and y to be the same!"
 );

Definition at line 400 of file logger.hpp.

#define MLOG_DEFAULT_TEST_DEBUG (   cond,
  msg 
)    MLOG_DEFAULT_TEST(MLOG_LEVEL_DEBUG, cond, msg)

Definition at line 439 of file logger.hpp.

#define MLOG_DEFAULT_TEST_ERROR (   cond,
  msg 
)    MLOG_DEFAULT_TEST(MLOG_LEVEL_ERROR, cond, msg)

Definition at line 442 of file logger.hpp.

#define MLOG_DEFAULT_TEST_FATAL (   cond,
  msg 
)    MLOG_DEFAULT_TEST(MLOG_LEVEL_FATAL, cond, msg)

Definition at line 443 of file logger.hpp.

#define MLOG_DEFAULT_TEST_INFO (   cond,
  msg 
)    MLOG_DEFAULT_TEST(MLOG_LEVEL_INFO, cond, msg)

Definition at line 440 of file logger.hpp.

#define MLOG_DEFAULT_TEST_TRACE (   cond,
  msg 
)    MLOG_DEFAULT_TEST(MLOG_LEVEL_TRACE, cond, msg)

Alternatives to MLOG_DEFAULT_TEST, where the logging level is part of the macro name rather than passed as a parameter. Which you use is entirely up to you.

Definition at line 438 of file logger.hpp.

#define MLOG_DEFAULT_TEST_WARN (   cond,
  msg 
)    MLOG_DEFAULT_TEST(MLOG_LEVEL_WARN, cond, msg)

Definition at line 441 of file logger.hpp.

#define MLOG_DEFAULT_THROW (   cond,
  msg 
)    MLOG_THROW(cond, MLOG_DEFAULT_LOGGER(), msg)

Default logging macro for checking false predicate results.

Allows you to check an expression and if it's false it will log it to an anonymous logger as an error and then throw a runtime_error exception.

Parameters:
[in]cond,:A predicate condition that will be tested
[in]msg,:Stream expression that will be rendered as a message
 MLOG_DEFAULT_THROW(
    (x == y),
    "Expected x and y to be the same!"
 );

Definition at line 630 of file logger.hpp.

#define MLOG_DEFAULT_THROW_IF (   cond,
  msg 
)    MLOG_THROW_IF(cond, MLOG_DEFAULT_LOGGER(), msg)

Default macro to either throw or log an error.

Parameters:
[in]cond,:If true, throw an exception, otherwise log an error
[in]msg,:Stream expression that will be rendered as a message
 MLOG_DEFAULT_THROW_IF(
    do_throw,
    "something's clearly wrong here"
 );

Definition at line 647 of file logger.hpp.

#define MLOG_DEFAULT_TRACE (   msg)    MLOG_DEFAULT(MLOG_LEVEL_TRACE, msg)

Alternatives to MLOG_DEFAULT, where the logging level is part of the macro name rather than passed as a parameter. Which you use is entirely up to you.

Definition at line 250 of file logger.hpp.

#define MLOG_DEFAULT_VERIFY (   cond,
  msg 
)    MLOG_VERIFY(cond, MLOG_DEFAULT_LOGGER(), msg)

Default logging macro for checking false predicate results.

Allows you to verify an expression and if it's false and if it's false it will log an error to an anonymous logger. If NDEBUG is define a runtime_error exception is thrown otherwise a runtime assert is generate.

Parameters:
[in]cond,:A predicate condition that will be tested
[in]msg,:Stream expression that will be rendered as a message
 MLOG_DEFAULT_VERIFY(
    (x == y),
    "Expected x and y to be the same!"
 );

Definition at line 722 of file logger.hpp.

#define MLOG_DEFAULT_WARN (   msg)    MLOG_DEFAULT(MLOG_LEVEL_WARN, msg)

Definition at line 253 of file logger.hpp.

#define MLOG_ERROR (   logger,
  msg 
)    MLOG(MLOG_LEVEL_ERROR, logger, msg)

Definition at line 117 of file logger.hpp.

#define MLOG_FATAL (   logger,
  msg 
)    MLOG(MLOG_LEVEL_FATAL, logger, msg)

Definition at line 118 of file logger.hpp.

#define MLOG_GET_LEVEL_ALL   log4cxx::Level::getAll()

Get logging level objects.

These macros can be used to obtain the appropriate logging framework object for a given level

Definition at line 733 of file logger.hpp.

#define MLOG_GET_LEVEL_DEBUG   log4cxx::Level::getDebug()

Definition at line 736 of file logger.hpp.

#define MLOG_GET_LEVEL_ERROR   log4cxx::Level::getError()

Definition at line 739 of file logger.hpp.

#define MLOG_GET_LEVEL_FATAL   log4cxx::Level::getFatal()

Definition at line 740 of file logger.hpp.

#define MLOG_GET_LEVEL_INFO   log4cxx::Level::getInfo()

Definition at line 737 of file logger.hpp.

#define MLOG_GET_LEVEL_OFF   log4cxx::Level::getOff()

Definition at line 734 of file logger.hpp.

#define MLOG_GET_LEVEL_TRACE   log4cxx::Level::getTrace()

Definition at line 735 of file logger.hpp.

#define MLOG_GET_LEVEL_WARN   log4cxx::Level::getWarn()

Definition at line 738 of file logger.hpp.

#define MLOG_GET_LEVELSTR_ALL   "all"

Names of the standard logging levels.

These macros are the string representaion of the level objects

Definition at line 834 of file logger.hpp.

#define MLOG_GET_LEVELSTR_DEBUG   "debug"

Definition at line 837 of file logger.hpp.

#define MLOG_GET_LEVELSTR_ERROR   "error"

Definition at line 840 of file logger.hpp.

#define MLOG_GET_LEVELSTR_FATAL   "fatal"

Definition at line 841 of file logger.hpp.

#define MLOG_GET_LEVELSTR_INFO   "info"

Definition at line 838 of file logger.hpp.

#define MLOG_GET_LEVELSTR_OFF   "off"

Definition at line 835 of file logger.hpp.

#define MLOG_GET_LEVELSTR_TRACE   "trace"

Definition at line 836 of file logger.hpp.

#define MLOG_GET_LEVELSTR_WARN   "warn"

Definition at line 839 of file logger.hpp.

#define MLOG_INFO (   logger,
  msg 
)    MLOG(MLOG_LEVEL_INFO, logger, msg)

Definition at line 115 of file logger.hpp.

#define MLOG_LEVEL_DEBUG   LOG4CXX_DEBUG

Definition at line 76 of file logger.hpp.

#define MLOG_LEVEL_ERROR   LOG4CXX_ERROR

Definition at line 79 of file logger.hpp.

#define MLOG_LEVEL_FATAL   LOG4CXX_FATAL

Definition at line 80 of file logger.hpp.

#define MLOG_LEVEL_INFO   LOG4CXX_INFO

Definition at line 77 of file logger.hpp.

#define MLOG_LEVEL_TRACE   LOG4CXX_TRACE

Loggin macros.

These macros directly invoke the underlying logging framework and exist to abstact MLOG from the underlying

Definition at line 75 of file logger.hpp.

#define MLOG_LEVEL_WARN   LOG4CXX_WARN

Definition at line 78 of file logger.hpp.

#define MLOG_NAMED (   level,
  name,
  msg 
)    MLOG(level, MLOG_NAMED_LOGGER(name), msg)

Log to a named logger.

Allows logging to a named logger without the need to explicitly create it.

Parameters:
[in]level,:The logging level MLOG_[TRACE, DEBUG, INFO, WARN, ERROR and FATAL]
[in]name,:The name to associate with the logger
[in]msg,:Stream expression that will be rendered as a message
 MLOG_NAMED(MLOG_LEVEL_WARN, "some logger", "some value: " << 394)

Definition at line 189 of file logger.hpp.

#define MLOG_NAMED_ASSERT (   cond,
  name,
  msg 
)    MLOG_ASSERT(cond, MLOG_NAMED_LOGGER(name), msg)

Named logging macro for asserts.

Allows you to assert an expression and if it's false it will log an error to a named logger and then generate a runtime assert if NDEBUG is not defined.

Parameters:
[in]cond,:A predicate condition that will be tested
[in]name,:The name to associate with the logger
[in]msg,:Stream expression that will be rendered as a message
 MLOG_NAMED_ASSERT(
    (x == y),
    "some logger",
    "Expected x and y to be the same!"
 );

Definition at line 305 of file logger.hpp.

#define MLOG_NAMED_CHECK (   cond,
  name,
  msg 
)    MLOG_CHECK(cond, MLOG_NAMED_LOGGER(name), msg)

Named logging macro for checking predicate predicate results.

Allows you to check an expression and if it's false it will log it to a named logger as an error.

Parameters:
[in]cond,:A predicate condition that will be tested
[in]name,:The name to associate with the logger
[in]msg,:Stream expression that will be rendered as a message
 MLOG_NAMED_CHECK(
    (x == y),
    "some logger",
    "Expected x and y to be the same!"
 );

Definition at line 489 of file logger.hpp.

#define MLOG_NAMED_DEBUG (   name,
  msg 
)    MLOG_NAMED(MLOG_LEVEL_DEBUG, name, msg)

Definition at line 200 of file logger.hpp.

#define MLOG_NAMED_DEFINE (   logger,
  name 
)    log4cxx::LoggerPtr logger = MLOG_NAMED_LOGGER(name)

Creates a named logger type.

The name is arbitrary but can be used in the config file to provide granular control over the formatting and logging levels specific to this logger.

Parameters:
[out]logger,:The name of the logger type being created
[in]name,:The name to associate with the logger
 MLOG_NAMED_DEFINE(my_logger, "some logger");
 MLOG(MLOG_LEVEL_DEBUG, my_logger, "log this: " << 944534634578UL);

Definition at line 170 of file logger.hpp.

#define MLOG_NAMED_ERROR (   name,
  msg 
)    MLOG_NAMED(MLOG_LEVEL_ERROR, name, msg)

Definition at line 203 of file logger.hpp.

#define MLOG_NAMED_FATAL (   name,
  msg 
)    MLOG_NAMED(MLOG_LEVEL_FATAL, name, msg)

Definition at line 204 of file logger.hpp.

#define MLOG_NAMED_INFO (   name,
  msg 
)    MLOG_NAMED(MLOG_LEVEL_INFO, name, msg)

Definition at line 201 of file logger.hpp.

#define MLOG_NAMED_LOGGER (   name)    log4cxx::Logger::getLogger(name)

Gets a named logger.

Return a logger with a given name

Parameters:
[in]name,:The name to associate with the logger
 MLOG(MLOG_LEVEL_DEBUG,  MLOG_NAMED_LOGGER("some logger"), "log this: " << 944534634578UL);

Definition at line 134 of file logger.hpp.

#define MLOG_NAMED_TEST (   level,
  cond,
  name,
  msg 
)    MLOG(level, cond, MLOG_NAMED_LOGGER(name), msg)

Named logging macro for logging false predicate results.

Allows you to test an expression and if it's false it will log it to a named logger at the desired level.

Parameters:
[in]level,:The logging level MLOG_[TRACE, DEBUG, INFO, WARN, ERROR and FATAL]
[in]cond,:A predicate condition that will be tested
[in]name,:The name to associate with the logger
[in]msg,:Stream expression that will be rendered as a message
 MLOG_NAMED_TEST(
    MLOG_LEVEL_DEBUG
    (x == y),
    "some logger",
    "Expected x and y to be the same!"
 );

Definition at line 377 of file logger.hpp.

#define MLOG_NAMED_TEST_DEBUG (   cond,
  name,
  msg 
)    MLOG_DEFAULT_TEST(MLOG_LEVEL_DEBUG, cond, name, msg)

Definition at line 425 of file logger.hpp.

#define MLOG_NAMED_TEST_ERROR (   cond,
  name,
  msg 
)    MLOG_DEFAULT_TEST(MLOG_LEVEL_ERROR, cond, name, msg)

Definition at line 428 of file logger.hpp.

#define MLOG_NAMED_TEST_FATAL (   cond,
  name,
  msg 
)    MLOG_DEFAULT_TEST(MLOG_LEVEL_FATAL, cond, name, msg)

Definition at line 429 of file logger.hpp.

#define MLOG_NAMED_TEST_INFO (   cond,
  name,
  msg 
)    MLOG_DEFAULT_TEST(MLOG_LEVEL_INFO, cond, name, msg)

Definition at line 426 of file logger.hpp.

#define MLOG_NAMED_TEST_TRACE (   cond,
  name,
  msg 
)    MLOG_DEFAULT_TEST(MLOG_LEVEL_TRACE, cond, name, msg)

Alternatives to MLOG_NAMED_TEST, where the logging level is part of the macro name rather than passed as a parameter. Which you use is entirely up to you.

Definition at line 424 of file logger.hpp.

#define MLOG_NAMED_TEST_WARN (   cond,
  name,
  msg 
)    MLOG_DEFAULT_TEST(MLOG_LEVEL_WARN, cond, name, msg)

Definition at line 427 of file logger.hpp.

#define MLOG_NAMED_THROW (   cond,
  name,
  msg 
)    MLOG_THROW(cond, MLOG_NAMED_LOGGER(name), msg)

Named logging macro for checking predicate predicate results.

Allows you to check an expression and if it's false it will log it to a named logger as an error and then throw a runtime_error exception.

Parameters:
[in]cond,:A predicate condition that will be tested
[in]name,:The name to associate with the logger
[in]msg,:Stream expression that will be rendered as a message
 MLOG_NAMED_THROW(
    (x == y),
    "some logger",
    "Expected x and y to be the same!"
 );

Definition at line 590 of file logger.hpp.

#define MLOG_NAMED_THROW_IF (   cond,
  name,
  msg 
)    MLOG_THROW_IF(cond, MLOG_NAMED_LOGGER(name), msg)

Named macro to either throw or log an error.

Parameters:
[in]cond,:If true, throw an exception, otherwise log an error
[in]name,:The name to associate with the logger
[in]msg,:Stream expression that will be rendered as a message
 MLOG_NAMED_THROW_IF(
    do_throw,
    "some logger",
    "something's clearly wrong here"
 );

Definition at line 609 of file logger.hpp.

#define MLOG_NAMED_TRACE (   name,
  msg 
)    MLOG_NAMED(MLOG_LEVEL_TRACE, name, msg)

Alternatives to MLOG_NAMED, where the logging level is part of the macro name rather than passed as a parameter. Which you use is entirely up to you.

Definition at line 199 of file logger.hpp.

#define MLOG_NAMED_VERIFY (   cond,
  name,
  msg 
)    MLOG_VERIFY(cond, MLOG_NAMED_LOGGER(name), msg)

Named logging macro for checking predicate predicate results.

Allows you to verify an expression and if it's false and if it's false it will log an error to a named logger. If NDEBUG is define a runtime_error exception is thrown otherwise a runtime assert is generate.

Parameters:
[in]cond,:A predicate condition that will be tested
[in]name,:The name to associate with the logger
[in]msg,:Stream expression that will be rendered as a message
 MLOG_NAMED_VERIFY(
    (x == y),
    "some logger",
    "Expected x and y to be the same!"
 );

Definition at line 700 of file logger.hpp.

#define MLOG_NAMED_WARN (   name,
  msg 
)    MLOG_NAMED(MLOG_LEVEL_WARN, name, msg)

Definition at line 202 of file logger.hpp.

#define MLOG_PREFIX__ (   msg)    msg

Log message prefix.

Copyright © 2008-2013 Last.fm Limited

This file is part of libmoost.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

/file Logging framework

The logging is all handled by Apache log4cxx.

Please refer to the online documentation for more information.

http://logging.apache.org/log4cxx/index.html

This macro can be defined at a project level to provide a prefix for all logged messages. It's entirely optional and can be igored.

Definition at line 64 of file logger.hpp.

#define MLOG_SET_DEFAULT_LEVEL (   level)    MLOG_SET_LEVEL(level, MLOG_DEFAULT_LOGGER())

Programatically set the level of the default (root) logger.

This macro allows you to change the logging level of the default logger. Use with caution because you might be overriding settings defined in a configuration file.

Definition at line 775 of file logger.hpp.

Alternatives to MLOG_SET_LEVEL, where the logging level is part of the macro name rather than passed as a parameter. Which you use is entirely up to you.

Definition at line 817 of file logger.hpp.

#define MLOG_SET_DEFAULT_LEVELSTR (   levelstr)    MLOG_SET_LEVELSTR(levelstr, MLOG_DEFAULT_LOGGER())

This macro allows you to change the logging level of the default logger using a string representation of its name. Use with caution because you might be overriding settings defined in a configuration file.

Definition at line 902 of file logger.hpp.

#define MLOG_SET_LEVEL (   level,
  logger 
)    logger->setLevel(level);

Programatically set the level of a logger.

This macro allows you to change the logging level of a specified logger. Use with caution because you might be overriding settings defined in a configuration file.

Definition at line 751 of file logger.hpp.

#define MLOG_SET_LEVEL_ALL (   logger)    MLOG_SET_LEVEL(MLOG_GET_LEVEL_ALL, logger)

Alternatives to MLOG_SET_LEVEL, where the logging level is part of the macro name rather than passed as a parameter. Which you use is entirely up to you.

Definition at line 785 of file logger.hpp.

#define MLOG_SET_LEVEL_DEBUG (   logger)    MLOG_SET_LEVEL(MLOG_GET_LEVEL_DEBUG, logger)

Definition at line 788 of file logger.hpp.

#define MLOG_SET_LEVEL_ERROR (   logger)    MLOG_SET_LEVEL(MLOG_GET_LEVEL_ERROR, logger)

Definition at line 791 of file logger.hpp.

#define MLOG_SET_LEVEL_FATAL (   logger)    MLOG_SET_LEVEL(MLOG_GET_LEVEL_FATAL, logger)

Definition at line 792 of file logger.hpp.

#define MLOG_SET_LEVEL_INFO (   logger)    MLOG_SET_LEVEL(MLOG_GET_LEVEL_INFO, logger)

Definition at line 789 of file logger.hpp.

#define MLOG_SET_LEVEL_OFF (   logger)    MLOG_SET_LEVEL(MLOG_GET_LEVEL_OFF, logger)

Definition at line 786 of file logger.hpp.

#define MLOG_SET_LEVEL_TRACE (   logger)    MLOG_SET_LEVEL(MLOG_GET_LEVEL_TRACE, logger)

Definition at line 787 of file logger.hpp.

#define MLOG_SET_LEVEL_WARN (   logger)    MLOG_SET_LEVEL(MLOG_GET_LEVEL_WARN, logger)

Definition at line 790 of file logger.hpp.

#define MLOG_SET_LEVELSTR (   levelstr,
  logger 
)    MLOG_SET_LEVEL(moost::logging::str2level(levelstr), logger);

Programatically set the level of a logger.

This macro allows you to change the logging level of a specified logger using a string representation of its name. Use with caution because you might be overriding settings defined in a configuration file.

Definition at line 880 of file logger.hpp.

#define MLOG_SET_NAMED_LEVEL (   level,
  name 
)    MLOG_SET_LEVEL(level, MLOG_NAMED_LOGGER(name))

Programatically set the level of a named logger.

This macro allows you to change the logging level of a named logger. Use with caution because you might be overriding settings defined in a configuration file.

Definition at line 763 of file logger.hpp.

Alternatives to MLOG_SET_LEVEL, where the logging level is part of the macro name rather than passed as a parameter. Which you use is entirely up to you.

Definition at line 801 of file logger.hpp.

Definition at line 804 of file logger.hpp.

Definition at line 807 of file logger.hpp.

Definition at line 808 of file logger.hpp.

Definition at line 805 of file logger.hpp.

Definition at line 802 of file logger.hpp.

Definition at line 803 of file logger.hpp.

Definition at line 806 of file logger.hpp.

#define MLOG_SET_NAMED_LEVELSTR (   levelstr,
  name 
)    MLOG_SET_LEVELSTR(levelstr, MLOG_NAMED_LOGGER(name))

Programatically set the level of the default (root) logger.

This macro allows you to change the logging level of a named logger using a string representation of its name. Use with caution because you might be overriding settings defined in a configuration file.

Definition at line 892 of file logger.hpp.

#define MLOG_TEST (   level,
  cond,
  logger,
  msg 
)    if(!(cond)) MLOG(level, logger, msg);

Logging macro for logging false predicate results.

All test logging is performed using this macro. It provides an abstraction from log4cxx and will allow you to test an expression and if it's false it will log it at the desired level.

Parameters:
[in]level,:The logging level MLOG_[TRACE, DEBUG, INFO, WARN, ERROR and FATAL]
[in]cond,:A predicate condition that will be tested
[in]logger,:Logger object
[in]msg,:Stream expression that will be rendered as a message
 MLOG_TEST(
    MLOG_LEVEL_DEBUG
    (x == y),
    MLOG_DEFAULT_LOGGER(),
    "Expected x and y to be the same!"
 );

Definition at line 352 of file logger.hpp.

#define MLOG_TEST_DEBUG (   cond,
  logger,
  msg 
)    MLOG_TEST(MLOG_LEVEL_DEBUG, cond, logger, msg)

Definition at line 411 of file logger.hpp.

#define MLOG_TEST_ERROR (   cond,
  logger,
  msg 
)    MLOG_TEST(MLOG_LEVEL_ERROR, cond, logger, msg)

Definition at line 414 of file logger.hpp.

#define MLOG_TEST_FATAL (   cond,
  logger,
  msg 
)    MLOG_TEST(MLOG_LEVEL_FATAL, cond, logger, msg)

Definition at line 415 of file logger.hpp.

#define MLOG_TEST_INFO (   cond,
  logger,
  msg 
)    MLOG_TEST(MLOG_LEVEL_INFO, cond, logger, msg)

Definition at line 412 of file logger.hpp.

#define MLOG_TEST_TRACE (   cond,
  logger,
  msg 
)    MLOG_TEST(MLOG_LEVEL_TRACE, cond, logger, msg)

Alternatives to MLOG_TEST, where the logging level is part of the macro name rather than passed as a parameter. Which you use is entirely up to you.

Definition at line 410 of file logger.hpp.

#define MLOG_TEST_WARN (   cond,
  logger,
  msg 
)    MLOG_TEST(MLOG_LEVEL_WARN, cond, logger, msg)

Definition at line 413 of file logger.hpp.

#define MLOG_THROW (   cond,
  logger,
  msg 
)
Value:
if(!(cond)) \
   { \
      MLOG_CHECK(false, logger, msg); \
      std::stringstream oss; \
      oss << msg; \
      throw std::runtime_error(oss.str()); \
   }

Logging macro for checking predicate results.

All throw logging is performed using this macro. It provides an abstraction from log4cxx and will allow you to check an expression and if it's false it will log an error and then throw a runtime_error exception.

Parameters:
[in]cond,:A predicate condition that will be tested
[in]logger,:Logger object
[in]msg,:Stream expression that will be rendered as a message
 MLOG_THROW(
    (x == y),
    MLOG_DEFAULT_LOGGER(),
    "Expected x and y to be the same!"
 );

Definition at line 534 of file logger.hpp.

#define MLOG_THROW_IF (   cond,
  logger,
  msg 
)
Value:
do { \
      std::ostringstream oss; \
      oss << msg; \
      const std::string& err = oss.str(); \
      if (cond) \
         throw std::runtime_error(err); \
      else \
         MLOG_ERROR(logger, err); \
   } while (0)

Macro to either throw or log an error.

Parameters:
[in]cond,:If true, throw an exception, otherwise log an error
[in]logger,:Logger object
[in]msg,:Stream expression that will be rendered as a message
 MLOG_THROW_IF(
    do_throw,
    MLOG_DEFAULT_LOGGER(),
    "something's clearly wrong here"
 );

Definition at line 559 of file logger.hpp.

#define MLOG_TRACE (   logger,
  msg 
)    MLOG(MLOG_LEVEL_TRACE, logger, msg)

Alternatives to MLOG, where the logging level is part of the macro name rather than passed as a parameter. Which you use is entirely up to you.

Definition at line 113 of file logger.hpp.

#define MLOG_VERIFY (   cond,
  logger,
  msg 
)
Value:
if(!(cond)) \
   { \
      MLOG_ASSERT(false, logger, msg); \
      throw std::runtime_error(msg); \
   }

Logging macro for checking predicate results.

All verify logging is performed using this macro. It provides an abstraction from log4cxx and will allow you to check an expression and if it's false it will log an error. If NDEBUG is define a runtime_error exception is thrown otherwise a runtime assert is generate.

Parameters:
[in]cond,:A predicate condition that will be tested
[in]logger,:Logger object
[in]msg,:Stream expression that will be rendered as a message
 MLOG_VERIFY(
    (x == y),
    MLOG_DEFAULT_LOGGER(),
    "Expected x and y to be the same!"
 );

Definition at line 672 of file logger.hpp.

#define MLOG_WARN (   logger,
  msg 
)    MLOG(MLOG_LEVEL_WARN, logger, msg)

Definition at line 116 of file logger.hpp.