22 #ifndef NDN_UTIL_LOGGING_HPP 23 #define NDN_UTIL_LOGGING_HPP 27 #ifdef HAVE_NDN_CXX_CUSTOM_LOGGER 28 #include "ndn-cxx/util/custom-logging.hpp" 31 #include <boost/log/sinks.hpp> 33 #include <unordered_map> 51 static std::set<std::string>
95 setDestination(boost::shared_ptr<boost::log::sinks::sink> destination);
117 static boost::shared_ptr<boost::log::sinks::sink>
124 addLoggerImpl(
Logger& logger);
127 registerLoggerNameImpl(std::string name);
129 std::set<std::string>
130 getLoggerNamesImpl()
const;
145 findLevel(std::string moduleName)
const;
148 setLevelImpl(
const std::string& prefix,
LogLevel level);
151 setLevelImpl(
const std::string& config);
154 setDestinationImpl(boost::shared_ptr<boost::log::sinks::sink> sink);
163 #ifdef NDN_CXX_HAVE_TESTS 165 removeLogger(
Logger& logger);
170 boost::shared_ptr<boost::log::sinks::sink>
171 getDestination()
const;
174 setLevelImpl(
const std::unordered_map<std::string, LogLevel>& prefixRules);
176 const std::unordered_map<std::string, LogLevel>&
178 #endif // NDN_CXX_HAVE_TESTS 183 mutable std::mutex m_mutex;
184 std::unordered_map<std::string, LogLevel> m_enabledLevel;
185 std::unordered_multimap<std::string, Logger*> m_loggers;
187 boost::shared_ptr<boost::log::sinks::sink> m_destination;
190 inline std::set<std::string>
193 return get().getLoggerNamesImpl();
199 get().setLevelImpl(prefix, level);
205 get().setLevelImpl(config);
211 get().setDestinationImpl(std::move(destination));
223 #endif // HAVE_NDN_CXX_CUSTOM_LOGGER 225 #endif // NDN_UTIL_LOGGING_HPP Controls the logging facility.
static void setLevel(const std::string &prefix, LogLevel level)
Set severity level.
LogLevel
Indicates the severity level of a log message.
Common includes and macros used throughout the library.
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
static void flush()
Flush log backend.
static boost::shared_ptr< boost::log::sinks::sink > makeDefaultStreamDestination(shared_ptr< std::ostream > os, bool wantAutoFlush=true)
Create stream log destination using default formatting.
Represents a log module in the logging facility.
static std::set< std::string > getLoggerNames()
Get list of all registered logger names.
static void setDestination(boost::shared_ptr< boost::log::sinks::sink > destination)
Set or replace log destination.