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> 51 static std::set<std::string>
111 addLoggerImpl(
Logger& logger);
114 registerLoggerNameImpl(std::string name);
116 std::set<std::string>
117 getLoggerNamesImpl()
const;
132 findLevel(std::string moduleName)
const;
135 setLevelImpl(
const std::string& prefix,
LogLevel level);
138 setLevelImpl(
const std::string& config);
141 setDestinationImpl(shared_ptr<std::ostream> os);
150 #ifdef NDN_CXX_HAVE_TESTS 152 removeLogger(
Logger& logger);
157 shared_ptr<std::ostream>
158 getDestination()
const;
161 setLevelImpl(
const std::unordered_map<std::string, LogLevel>& prefixRules);
163 const std::unordered_map<std::string, LogLevel>&
165 #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 using Sink = boost::log::sinks::asynchronous_sink<boost::log::sinks::text_ostream_backend>;
175 boost::shared_ptr<Sink> m_sink;
176 shared_ptr<std::ostream> m_destination;
179 inline std::set<std::string>
182 return get().getLoggerNamesImpl();
188 get().setLevelImpl(prefix, level);
194 get().setLevelImpl(config);
200 get().setDestinationImpl(std::move(os));
212 #endif // HAVE_NDN_CXX_CUSTOM_LOGGER 214 #endif // NDN_UTIL_LOGGING_HPP Controls the logging facility.
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 log module in the logging facility.
static std::set< std::string > getLoggerNames()
Get list of all registered logger names.