22 #ifndef NDN_UTIL_LOGGER_HPP
23 #define NDN_UTIL_LOGGER_HPP
25 #include "../common.hpp"
27 #ifdef HAVE_NDN_CXX_CUSTOM_LOGGER
28 #include "ndn-cxx-custom-logger.hpp"
31 #include <boost/log/common.hpp>
32 #include <boost/log/sources/logger.hpp>
66 class Logger :
public boost::log::sources::logger_mt
70 Logger(
const std::string& name);
81 return m_currentLevel.load(std::memory_order_relaxed) >= level;
87 m_currentLevel.store(level, std::memory_order_relaxed);
91 const std::string m_moduleName;
92 std::atomic<LogLevel> m_currentLevel;
97 #define NDN_LOG_INIT(name) \
99 inline ::ndn::util::Logger& getNdnCxxLogger() \
101 static ::ndn::util::Logger logger(BOOST_STRINGIZE(name)); \
105 struct ndn_cxx__allow_trailing_semicolon
122 #if (BOOST_VERSION >= 105900) && (BOOST_VERSION < 106000)
124 #define NDN_BOOST_LOG(x) BOOST_LOG(x) << ""
126 #define NDN_BOOST_LOG(x) BOOST_LOG(x)
129 #define NDN_LOG(lvl, lvlstr, expression) \
131 if (getNdnCxxLogger().isLevelEnabled(::ndn::util::LogLevel::lvl)) { \
132 NDN_BOOST_LOG(getNdnCxxLogger()) << ::ndn::util::LoggerTimestamp{} \
133 << " " BOOST_STRINGIZE(lvlstr) ": [" << getNdnCxxLogger().getModuleName() << "] " \
141 #define NDN_LOG_TRACE(expression) NDN_LOG(TRACE, TRACE, expression)
146 #define NDN_LOG_DEBUG(expression) NDN_LOG(DEBUG, DEBUG, expression)
151 #define NDN_LOG_INFO(expression) NDN_LOG(INFO, INFO, expression)
156 #define NDN_LOG_WARN(expression) NDN_LOG(WARN, WARNING, expression)
161 #define NDN_LOG_ERROR(expression) NDN_LOG(ERROR, ERROR, expression)
166 #define NDN_LOG_FATAL(expression) NDN_LOG(FATAL, FATAL, expression)
171 #endif // HAVE_NDN_CXX_CUSTOM_LOGGER
173 #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