22 #ifndef NDN_UTIL_LOGGING_HPP 23 #define NDN_UTIL_LOGGING_HPP 25 #include "../common.hpp" 27 #ifdef HAVE_NDN_CXX_CUSTOM_LOGGER 28 #include "ndn-cxx-custom-logging.hpp" 31 #include <boost/log/sinks.hpp> 33 #include <unordered_map> 57 static std::set<std::string>
116 addLoggerImpl(
Logger& logger);
118 std::set<std::string>
119 getLoggerNamesImpl()
const;
134 findLevel(
const std::string& moduleName)
const;
137 setLevelImpl(
const std::string& prefix,
LogLevel level);
140 setLevelImpl(
const std::string& config);
143 setDestinationImpl(shared_ptr<std::ostream> os);
152 #ifdef NDN_CXX_HAVE_TESTS 154 removeLogger(
Logger& logger);
159 shared_ptr<std::ostream>
160 getDestination()
const;
163 setLevelImpl(
const std::unordered_map<std::string, LogLevel>& prefixRules);
165 const std::unordered_map<std::string, LogLevel>&
167 #endif // NDN_CXX_HAVE_TESTS 170 mutable std::mutex m_mutex;
171 std::unordered_map<std::string, LogLevel> m_enabledLevel;
172 std::unordered_multimap<std::string, Logger*> m_loggers;
174 shared_ptr<std::ostream> m_destination;
175 typedef boost::log::sinks::asynchronous_sink<boost::log::sinks::text_ostream_backend> Sink;
176 boost::shared_ptr<Sink> m_sink;
182 get().addLoggerImpl(logger);
185 inline std::set<std::string>
188 return get().getLoggerNamesImpl();
194 get().setLevelImpl(prefix, level);
200 get().setLevelImpl(config);
206 get().setDestinationImpl(std::move(os));
218 #endif // HAVE_NDN_CXX_CUSTOM_LOGGER 220 #endif // NDN_UTIL_LOGGING_HPP controls the logging facility
static void addLogger(Logger &logger)
register a new logger
Copyright (c) 2013-2017 Regents of the University of California.
static void setLevel(const std::string &prefix, LogLevel level)
set severity level
static void setDestination(shared_ptr< std::ostream > os)
set log destination
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
LogLevel
indicates the severity level of a log message
static void flush()
flush log backend
represents a logger in logging facility
static std::set< std::string > getLoggerNames()
get list of names of all registered loggers