22 #ifndef NDN_UTIL_LOGGER_HPP
23 #define NDN_UTIL_LOGGER_HPP
25 #include "../common.hpp"
27 #include <boost/log/common.hpp>
28 #include <boost/log/sources/logger.hpp>
62 class Logger :
public boost::log::sources::logger_mt
66 Logger(
const std::string& name);
77 return m_currentLevel.load(std::memory_order_relaxed) >= level;
83 m_currentLevel.store(level, std::memory_order_relaxed);
87 const std::string m_moduleName;
88 std::atomic<LogLevel> m_currentLevel;
93 #define NDN_LOG_INIT(name) \
95 inline ::ndn::util::Logger& getNdnCxxLogger() \
97 static ::ndn::util::Logger logger(BOOST_STRINGIZE(name)); \
101 struct ndn_cxx__allow_trailing_semicolon
118 #if (BOOST_VERSION >= 105900) && (BOOST_VERSION < 106000)
120 #define NDN_BOOST_LOG(x) BOOST_LOG(x) << ""
122 #define NDN_BOOST_LOG(x) BOOST_LOG(x)
125 #define NDN_LOG(lvl, lvlstr, expression) \
127 if (getNdnCxxLogger().isLevelEnabled(::ndn::util::LogLevel::lvl)) { \
128 NDN_BOOST_LOG(getNdnCxxLogger()) << ::ndn::util::LoggerTimestamp{} \
129 << " " BOOST_STRINGIZE(lvlstr) ": [" << getNdnCxxLogger().getModuleName() << "] " \
137 #define NDN_LOG_TRACE(expression) NDN_LOG(TRACE, TRACE, expression)
142 #define NDN_LOG_DEBUG(expression) NDN_LOG(DEBUG, DEBUG, expression)
147 #define NDN_LOG_INFO(expression) NDN_LOG(INFO, INFO, expression)
152 #define NDN_LOG_WARN(expression) NDN_LOG(WARN, WARNING, expression)
157 #define NDN_LOG_ERROR(expression) NDN_LOG(ERROR, ERROR, expression)
162 #define NDN_LOG_FATAL(expression) NDN_LOG(FATAL, FATAL, expression)
167 #endif // NDN_UTIL_LOGGER_HPP
Copyright (c) 2013-2016 Regents of the University of California.
trace messages (most verbose)
a tag that writes a timestamp upon stream output
LogLevel
indicates the severity level of a log message
LogLevel parseLogLevel(const std::string &s)
parse LogLevel from string
Logger(const std::string &name)
std::ostream & operator<<(std::ostream &os, Digest< Hash > &digest)
represents a logger in logging facility
fatal (will be logged unconditionally)
const std::string & getModuleName() const
void setLevel(LogLevel level)
bool isLevelEnabled(LogLevel level) const