ndn::util::Logging Class Reference

controls the logging facility More...

#include <logging.hpp>

+ Inheritance diagram for ndn::util::Logging:
+ Collaboration diagram for ndn::util::Logging:

Static Public Member Functions

static void addLogger (Logger &logger)
 register a new logger More...
 
static void flush ()
 flush log backend More...
 
static std::set< std::string > getLoggerNames ()
 get list of names of all registered loggers More...
 
static void setDestination (shared_ptr< std::ostream > os)
 set log destination More...
 
static void setDestination (std::ostream &os)
 set log destination More...
 
static void setLevel (const std::string &prefix, LogLevel level)
 set severity level More...
 
static void setLevel (const std::string &config)
 set severity levels with a config string More...
 

Detailed Description

controls the logging facility

Note
Public static methods are thread safe. Non-public methods are not guaranteed to be thread safe.

Definition at line 46 of file logging.hpp.

Member Function Documentation

void ndn::util::Logging::addLogger ( Logger logger)
inlinestatic

register a new logger

Note
App should declare a new logger with NDN_LOG_INIT macro.

Definition at line 180 of file logging.hpp.

void ndn::util::Logging::flush ( )
inlinestatic

flush log backend

This ensures log messages are written to the destination stream.

Definition at line 210 of file logging.hpp.

std::set< std::string > ndn::util::Logging::getLoggerNames ( )
inlinestatic

get list of names of all registered loggers

Definition at line 186 of file logging.hpp.

void ndn::util::Logging::setDestination ( shared_ptr< std::ostream >  os)
inlinestatic

set log destination

Parameters
osa stream for log output

Initial destination is std::clog .

Definition at line 204 of file logging.hpp.

void ndn::util::Logging::setDestination ( std::ostream &  os)
static

set log destination

Parameters
osa stream for log output; caller must ensure this is valid until setDestination is invoked again or program exits

This is equivalent to setDestination(shared_ptr<std::ostream>(&os, nullDeleter))

Definition at line 200 of file logging.cpp.

void ndn::util::Logging::setLevel ( const std::string &  prefix,
LogLevel  level 
)
inlinestatic

set severity level

Parameters
prefixlogger prefix; this can be a specific logger name, a general prefix like ndn.a.* to apply a setting for all modules that contain this prefix, or "*" for all modules
levelminimum severity level

Log messages are output only if its severity is greater than the set minimum severity level. Initial default severity level is LogLevel::NONE which enables FATAL only.

Definition at line 192 of file logging.hpp.

void ndn::util::Logging::setLevel ( const std::string &  config)
inlinestatic

set severity levels with a config string

Parameters
configcolon-separate key=value pairs
Exceptions
std::invalid_argumentconfig string is malformed
Logging::setSeverityLevels("*=INFO:Face=DEBUG:NfdController=WARN");

is equivalent to

Logging::setSeverityLevel("*", LogLevel::INFO);
Logging::setSeverityLevel("Face", LogLevel::DEBUG);
Logging::setSeverityLevel("NfdController", LogLevel::WARN);

Definition at line 198 of file logging.hpp.