libmoost
/home/mhx/git/github/libmoost/include/moost/logging/function_logger.hpp
Go to the documentation of this file.
00001 /* vim:set ts=3 sw=3 sts=3 et: */
00028 #ifndef MOOST_FUNCTION_LOGGER_HPP
00029 #define MOOST_FUNCTION_LOGGER_HPP
00030 
00031 #include <string>
00032 #include <boost/current_function.hpp>
00033 #include "logger.hpp"
00034 #include "../utils/demangler.hpp"
00035 
00045 #define MLOG_FUNC_FULL_NAME() \
00046    BOOST_CURRENT_FUNCTION
00047 
00056 #define MLOG_FUNC_SHORT_NAME() \
00057    moost::utils::short_function_name(MLOG_FUNC_FULL_NAME())
00058 
00067 #if defined(NDEBUG) && !defined(MLOG_SHORT_FUNC_NAME_LOGGING)
00068 #define MLOG_FUNC_NAME() \
00069    MLOG_FUNC_FULL_NAME()
00070 #else
00071 #define MLOG_FUNC_NAME() \
00072    MLOG_FUNC_SHORT_NAME()
00073 #endif
00074 
00075 
00100 #define MLOG_FUNC_LOGGER() \
00101    log4cxx::Logger::getLogger(MLOG_FUNC_NAME())
00102 
00123 #define MLOG_FUNC_DEFINE(logger) \
00124    log4cxx::LoggerPtr logger = MLOG_FUNC_LOGGER()
00125 
00144 #define MLOG_FUNC(level, msg) \
00145    MLOG(level, MLOG_FUNC_LOGGER(), msg) \
00146 
00147 
00154 #define MLOG_FUNC_TRACE(msg) MLOG_FUNC(MLOG_LEVEL_TRACE, msg)
00155 #define MLOG_FUNC_DEBUG(msg) MLOG_FUNC(MLOG_LEVEL_DEBUG, msg)
00156 #define MLOG_FUNC_INFO(msg)  MLOG_FUNC(MLOG_LEVEL_INFO, msg)
00157 #define MLOG_FUNC_WARN(msg)  MLOG_FUNC(MLOG_LEVEL_WARN, msg)
00158 #define MLOG_FUNC_ERROR(msg) MLOG_FUNC(MLOG_LEVEL_ERROR, msg)
00159 #define MLOG_FUNC_FATAL(msg) MLOG_FUNC(MLOG_LEVEL_FATAL, msg)
00160 
00179 #define MLOG_FUNC_ASSERT(cond, msg) \
00180    MLOG_ASSERT(cond, MLOG_FUNC_LOGGER(), msg) \
00181 
00182 
00203 #define MLOG_FUNC_TEST(level, cond, msg) \
00204    MLOG_TEST(level, cond, MLOG_FUNC_LOGGER(), msg);
00205 
00213 #define MLOG_FUNC_TEST_TRACE(cond, msg) MLOG_FUNC_TEST(MLOG_LEVEL_TRACE, cond, msg)
00214 #define MLOG_FUNC_TEST_DEBUG(cond, msg) MLOG_FUNC_TEST(MLOG_LEVEL_DEBUG, cond, msg)
00215 #define MLOG_FUNC_TEST_INFO(cond, msg)  MLOG_FUNC_TEST(MLOG_LEVEL_INFO, cond, msg)
00216 #define MLOG_FUNC_TEST_WARN(cond, msg)  MLOG_FUNC_TEST(MLOG_LEVEL_WARN, cond, msg)
00217 #define MLOG_FUNC_TEST_ERROR(cond, msg) MLOG_FUNC_TEST(MLOG_LEVEL_ERROR, cond, msg)
00218 #define MLOG_FUNC_TEST_FATAL(cond, msg) MLOG_FUNC_TEST(MLOG_LEVEL_FATAL, cond, msg)
00219 
00239 #define MLOG_FUNC_CHECK(cond,  msg) \
00240    MLOG_FUNC_TEST_ERROR(cond, msg)
00241 
00261 #define MLOG_FUNC_THROW(cond,  msg)\
00262    MLOG_THROW(cond, MLOG_FUNC_LOGGER(), msg)
00263 
00278 #define MLOG_FUNC_THROW_IF(cond,  msg)\
00279    MLOG_THROW_IF(cond, MLOG_FUNC_LOGGER(), msg)
00280 
00301 #define MLOG_FUNC_VERIFY(cond,  msg)\
00302    MLOG_VERIFY(cond, MLOG_FUNC_LOGGER(), msg)
00303 
00304 
00314 #define MLOG_FUNC_SET_LEVEL(level) \
00315    MLOG_SET_LEVEL(level, MLOG_FUNC_LOGGER());
00316 
00324 #define MLOG_FUNC_SET_LEVEL_ALL() MLOG_FUNC_SET_LEVEL(MLOG_GET_LEVEL_ALL)
00325 #define MLOG_FUNC_SET_LEVEL_OFF() MLOG_FUNC_SET_LEVEL(MLOG_GET_LEVEL_OFF)
00326 #define MLOG_FUNC_SET_LEVEL_TRACE() MLOG_FUNC_SET_LEVEL(MLOG_GET_LEVEL_TRACE)
00327 #define MLOG_FUNC_SET_LEVEL_DEBUG() MLOG_FUNC_SET_LEVEL(MLOG_GET_LEVEL_DEBUG)
00328 #define MLOG_FUNC_SET_LEVEL_INFO() MLOG_FUNC_SET_LEVEL(MLOG_GET_LEVEL_INFO)
00329 #define MLOG_FUNC_SET_LEVEL_WARN() MLOG_FUNC_SET_LEVEL(MLOG_GET_LEVEL_WARN)
00330 #define MLOG_FUNC_SET_LEVEL_ERROR() MLOG_FUNC_SET_LEVEL(MLOG_GET_LEVEL_ERROR)
00331 #define MLOG_FUNC_SET_LEVEL_FATAL() MLOG_FUNC_SET_LEVEL(MLOG_GET_LEVEL_FATAL)
00332 
00342 #define MLOG_FUNC_SET_LEVELSTR(levelstr) \
00343    MLOG_SET_LEVEL(str2level(levelstr), MLOG_FUNC_LOGGER());
00344 
00345 #endif