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;
101 #define NDN_LOG_INIT(name) \ 103 inline ::ndn::util::Logger& getNdnCxxLogger() \ 105 static ::ndn::util::Logger logger(BOOST_STRINGIZE(name)); \ 109 struct ndn_cxx__allow_trailing_semicolon 126 #if (BOOST_VERSION >= 105900) && (BOOST_VERSION < 106000) 128 #define NDN_BOOST_LOG(x) BOOST_LOG(x) << "" 130 #define NDN_BOOST_LOG(x) BOOST_LOG(x) 133 #define NDN_LOG(lvl, lvlstr, expression) \ 135 if (getNdnCxxLogger().isLevelEnabled(::ndn::util::LogLevel::lvl)) { \ 136 NDN_BOOST_LOG(getNdnCxxLogger()) << ::ndn::util::LoggerTimestamp{} \ 137 << " " BOOST_STRINGIZE(lvlstr) ": [" << getNdnCxxLogger().getModuleName() << "] " \ 145 #define NDN_LOG_TRACE(expression) NDN_LOG(TRACE, TRACE, expression) 150 #define NDN_LOG_DEBUG(expression) NDN_LOG(DEBUG, DEBUG, expression) 155 #define NDN_LOG_INFO(expression) NDN_LOG(INFO, INFO, expression) 160 #define NDN_LOG_WARN(expression) NDN_LOG(WARN, WARNING, expression) 165 #define NDN_LOG_ERROR(expression) NDN_LOG(ERROR, ERROR, expression) 170 #define NDN_LOG_FATAL(expression) NDN_LOG(FATAL, FATAL, expression) 175 #endif // HAVE_NDN_CXX_CUSTOM_LOGGER 177 #endif // NDN_UTIL_LOGGER_HPP Copyright (c) 2013-2017 Regents of the University of California.
trace messages (most verbose)
std::ostream & operator<<(std::ostream &os, LogLevel level)
output LogLevel as string
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
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