logger.hpp File Reference
#include "ndn-cxx/detail/common.hpp"
#include <boost/log/common.hpp>
#include <boost/log/expressions/keyword.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <atomic>
+ Include dependency graph for logger.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  ndn::util::Logger
 Represents a log module in the logging facility. More...
 

Namespaces

 ndn
 
 ndn::util
 
 ndn::util::detail
 
 ndn::util::log
 

Macros

#define NDN_LOG_DEBUG(expression)   NDN_LOG_INTERNAL(DEBUG, expression)
 Log at DEBUG level. More...
 
#define NDN_LOG_ERROR(expression)   NDN_LOG_INTERNAL(ERROR, expression)
 Log at ERROR level. More...
 
#define NDN_LOG_FATAL(expression)   NDN_LOG_INTERNAL(FATAL, expression)
 Log at FATAL level. More...
 
#define NDN_LOG_INFO(expression)   NDN_LOG_INTERNAL(INFO, expression)
 Log at INFO level. More...
 
#define NDN_LOG_INIT(name)
 Define a non-member log module. More...
 
#define NDN_LOG_MEMBER_DECL()
 Declare a member log module, without initializing it. More...
 
#define NDN_LOG_MEMBER_DECL_SPECIALIZED(cls)
 Declare an explicit specialization of a member log module of a class template. More...
 
#define NDN_LOG_MEMBER_INIT(cls, name)
 Initialize a member log module. More...
 
#define NDN_LOG_MEMBER_INIT_SPECIALIZED(cls, name)
 Define an explicit specialization of a member log module of a class template. More...
 
#define NDN_LOG_TRACE(expression)   NDN_LOG_INTERNAL(TRACE, expression)
 Log at TRACE level. More...
 
#define NDN_LOG_WARN(expression)   NDN_LOG_INTERNAL(WARN, expression)
 Log at WARN level. More...
 

Enumerations

enum class  ndn::util::LogLevel {
  ndn::util::FATAL = -1 ,
  ndn::util::NONE = 0 ,
  ndn::util::ERROR = 1 ,
  ndn::util::WARN = 2 ,
  ndn::util::INFO = 3 ,
  ndn::util::DEBUG = 4 ,
  ndn::util::TRACE = 5 ,
  ndn::util::ALL = 255
}
 Indicates the severity level of a log message. More...
 

Functions

std::ostream & ndn::util::operator<< (std::ostream &os, LogLevel level)
 Output LogLevel as a string. More...
 
LogLevel ndn::util::parseLogLevel (const std::string &s)
 Parse LogLevel from a string. More...
 

Macro Definition Documentation

◆ NDN_LOG_DEBUG

#define NDN_LOG_DEBUG (   expression)    NDN_LOG_INTERNAL(DEBUG, expression)

Log at DEBUG level.

Precondition
A log module must be declared in the same translation unit, class, struct, or namespace.

Definition at line 254 of file logger.hpp.

◆ NDN_LOG_ERROR

#define NDN_LOG_ERROR (   expression)    NDN_LOG_INTERNAL(ERROR, expression)

Log at ERROR level.

Precondition
A log module must be declared in the same translation unit, class, struct, or namespace.

Definition at line 269 of file logger.hpp.

◆ NDN_LOG_FATAL

#define NDN_LOG_FATAL (   expression)    NDN_LOG_INTERNAL(FATAL, expression)

Log at FATAL level.

Precondition
A log module must be declared in the same translation unit, class, struct, or namespace.

Definition at line 274 of file logger.hpp.

◆ NDN_LOG_INFO

#define NDN_LOG_INFO (   expression)    NDN_LOG_INTERNAL(INFO, expression)

Log at INFO level.

Precondition
A log module must be declared in the same translation unit, class, struct, or namespace.

Definition at line 259 of file logger.hpp.

◆ NDN_LOG_INIT

#define NDN_LOG_INIT (   name)
Value:
namespace { \
const bool ndn_cxx_loggerRegistration __attribute__((used)) = NDN_LOG_REGISTER_NAME(name); \
::ndn::util::Logger& ndn_cxx_getLogger() \
NDN_LOG_INIT_FUNCTION_BODY(name) \
} \
struct ndn_cxx_allow_trailing_semicolon
Represents a log module in the logging facility.
Definition: logger.hpp:78

Define a non-member log module.

This macro can be used in global scope to define a log module for an entire translation unit, or in namespace scope to define a log module for the enclosing namespace. Use NDN_LOG_MEMBER_INIT to define a log module as a class or struct member.

Warning
Do not use this macro in header files unless you know what you're doing, as it can easily trigger ODR violations if used incorrectly.
Parameters
namethe logger name
Note
The logger name is restricted to alphanumeric characters and a select set of symbols: ~, #, %, _, <, >, ., -. It must not start or end with a dot (.), or contain multiple consecutive dots.

Definition at line 163 of file logger.hpp.

◆ NDN_LOG_MEMBER_DECL

#define NDN_LOG_MEMBER_DECL ( )
Value:
static ::ndn::util::Logger& ndn_cxx_getLogger(); \
private: \
static const bool ndn_cxx_loggerRegistration

Declare a member log module, without initializing it.

This macro should only be used to declare a log module as a class or struct member. It is recommended to place this macro in the private or protected section of the class or struct definition. Use NDN_LOG_INIT to declare a non-member log module.

If the enclosing class is a template, this macro can be used in conjunction with NDN_LOG_MEMBER_DECL_SPECIALIZED and NDN_LOG_MEMBER_INIT_SPECIALIZED to provide different loggers for different template specializations.

Definition at line 181 of file logger.hpp.

◆ NDN_LOG_MEMBER_DECL_SPECIALIZED

#define NDN_LOG_MEMBER_DECL_SPECIALIZED (   cls)
Value:
template<> \
const bool ::ndn::util::detail::ArgumentType<void(cls&)>::ndn_cxx_loggerRegistration; \
template<> \
::ndn::util::Logger& ::ndn::util::detail::ArgumentType<void(cls&)>::ndn_cxx_getLogger()

Declare an explicit specialization of a member log module of a class template.

Parameters
clsfully specialized class name; wrap in parentheses if it contains commas

Definition at line 209 of file logger.hpp.

◆ NDN_LOG_MEMBER_INIT

#define NDN_LOG_MEMBER_INIT (   cls,
  name 
)
Value:
const bool ::ndn::util::detail::ArgumentType<void(cls&)>::ndn_cxx_loggerRegistration = \
NDN_LOG_REGISTER_NAME(name); \
::ndn::util::Logger& ::ndn::util::detail::ArgumentType<void(cls&)>::ndn_cxx_getLogger() \
NDN_LOG_INIT_FUNCTION_BODY(name) \
struct ndn_cxx_allow_trailing_semicolon

Initialize a member log module.

This macro should only be used to initialize a previously declared member log module. It must be placed in a .cpp file (NOT in a header file), in the same namespace as the class or struct that contains the log module.

Parameters
clsclass name; wrap in parentheses if it contains commas
namethe logger name
Note
The logger name is restricted to alphanumeric characters and a select set of symbols: ~, #, %, _, <, >, ., -. It must not start or end with a dot (.), or contain multiple consecutive dots.

Definition at line 198 of file logger.hpp.

◆ NDN_LOG_MEMBER_INIT_SPECIALIZED

#define NDN_LOG_MEMBER_INIT_SPECIALIZED (   cls,
  name 
)
Value:
template<> \
const bool ::ndn::util::detail::ArgumentType<void(cls&)>::ndn_cxx_loggerRegistration = \
NDN_LOG_REGISTER_NAME(name); \
template<> \
::ndn::util::Logger& ::ndn::util::detail::ArgumentType<void(cls&)>::ndn_cxx_getLogger() \
NDN_LOG_INIT_FUNCTION_BODY(name) \
struct ndn_cxx_allow_trailing_semicolon

Define an explicit specialization of a member log module of a class template.

This macro must be placed in a .cpp file (NOT in a header file), in the same namespace as the class template that contains the log module.

Parameters
clsfully specialized class name; wrap in parentheses if it contains commas
namethe logger name
Note
The logger name is restricted to alphanumeric characters and a select set of symbols: ~, #, %, _, <, >, ., -. It must not start or end with a dot (.), or contain multiple consecutive dots.

Definition at line 226 of file logger.hpp.

◆ NDN_LOG_TRACE

#define NDN_LOG_TRACE (   expression)    NDN_LOG_INTERNAL(TRACE, expression)

Log at TRACE level.

Precondition
A log module must be declared in the same translation unit, class, struct, or namespace.

Definition at line 249 of file logger.hpp.

◆ NDN_LOG_WARN

#define NDN_LOG_WARN (   expression)    NDN_LOG_INTERNAL(WARN, expression)

Log at WARN level.

Precondition
A log module must be declared in the same translation unit, class, struct, or namespace.

Definition at line 264 of file logger.hpp.