26 #ifndef NFD_CORE_LOGGER_HPP 27 #define NFD_CORE_LOGGER_HPP 31 #ifdef HAVE_CUSTOM_LOGGER 32 #include "custom-logger.hpp" 34 #include <boost/log/common.hpp> 35 #include <boost/log/sources/logger.hpp> 66 return m_enabledLogLevel >= level;
72 m_enabledLogLevel = level;
91 std::string m_moduleName;
122 #define NFD_LOG_INIT(name) \ 123 static ::nfd::Logger& g_logger = ::nfd::LoggerFactory::create(name) 125 #define NFD_LOG_INCLASS_DECLARE() \ 126 static ::nfd::Logger& g_logger 128 #define NFD_LOG_INCLASS_DEFINE(cls, name) \ 129 ::nfd::Logger& cls::g_logger = ::nfd::LoggerFactory::create(name) 131 #define NFD_LOG_INCLASS_TEMPLATE_DEFINE(cls, name) \ 133 ::nfd::Logger& cls<T>::g_logger = ::nfd::LoggerFactory::create(name) 135 #define NFD_LOG_INCLASS_TEMPLATE_SPECIALIZATION_DEFINE(cls, specialization, name) \ 137 ::nfd::Logger& cls<specialization>::g_logger = ::nfd::LoggerFactory::create(name) 139 #define NFD_LOG_INCLASS_2TEMPLATE_SPECIALIZATION_DEFINE(cls, s1, s2, name) \ 141 ::nfd::Logger& cls<s1, s2>::g_logger = ::nfd::LoggerFactory::create(name) 143 #if (BOOST_VERSION >= 105900) && (BOOST_VERSION < 106000) 145 #define NFD_BOOST_LOG(x) BOOST_LOG(x) << "" 147 #define NFD_BOOST_LOG(x) BOOST_LOG(x) 150 #define NFD_LOG_LINE(msg, expression) \ 151 ::nfd::LoggerTimestamp{} << " "#msg": " << "[" << g_logger << "] " << expression 153 #define NFD_LOG(level, msg, expression) \ 155 if (g_logger.isEnabled(::nfd::LOG_##level)) { \ 156 NFD_BOOST_LOG(g_logger.boostLogger) << NFD_LOG_LINE(msg, expression); \ 160 #define NFD_LOG_TRACE(expression) NFD_LOG(TRACE, TRACE, expression) 161 #define NFD_LOG_DEBUG(expression) NFD_LOG(DEBUG, DEBUG, expression) 162 #define NFD_LOG_INFO(expression) NFD_LOG(INFO, INFO, expression) 163 #define NFD_LOG_WARN(expression) NFD_LOG(WARN, WARNING, expression) 164 #define NFD_LOG_ERROR(expression) NFD_LOG(ERROR, ERROR, expression) 165 #define NFD_LOG_FATAL(expression) NFD_LOG(FATAL, FATAL, expression) 169 #endif // HAVE_CUSTOM_LOGGER 171 #endif // NFD_CORE_LOGGER_HPP
a tag that writes a timestamp upon stream output
boost::log::sources::logger boostLogger
std::ostream & operator<<(std::ostream &os, const LoggerTimestamp &)
write a timestamp to os
bool isEnabled(LogLevel level) const
void setName(const std::string &name)
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
void setLogLevel(LogLevel level)
Logger(const std::string &name, LogLevel level)
LogLevel
indicates a log level
provides logging for a module
const std::string & getName() const