NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
logger.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
#ifndef NDN_UTIL_LOGGER_HPP
23
#define NDN_UTIL_LOGGER_HPP
24
25
#include "../common.hpp"
26
27
#ifdef HAVE_NDN_CXX_CUSTOM_LOGGER
28
#include "ndn-cxx-custom-logger.hpp"
29
#else
30
31
#include <atomic>
32
33
#include "ns3/log.h"
34
35
namespace
ndn
{
36
namespace
util {
37
40
enum class
LogLevel
{
41
FATAL
= -1,
42
NONE
= 0,
43
ERROR
= 1,
44
WARN
= 2,
45
INFO
= 3,
46
DEBUG
= 4,
47
TRACE
= 5,
48
ALL
= 255
49
};
50
54
std::ostream&
55
operator<<
(std::ostream& os,
LogLevel
level);
56
60
LogLevel
61
parseLogLevel
(
const
std::string& s);
62
66
class
Logger
67
{
68
public
:
69
explicit
70
Logger
(
const
std::string&
name
);
71
72
const
std::string&
73
getModuleName
()
const
74
{
75
return
m_moduleName;
76
}
77
78
bool
79
isLevelEnabled
(
LogLevel
level)
const
80
{
81
return
m_currentLevel.load(std::memory_order_relaxed) >= level;
82
}
83
84
void
85
setLevel
(
LogLevel
level)
86
{
87
m_currentLevel.store(level, std::memory_order_relaxed);
88
}
89
90
private
:
91
const
std::string m_moduleName;
92
std::atomic<LogLevel> m_currentLevel;
93
};
94
97
#define NDN_LOG_INIT(name) NS_LOG_COMPONENT_DEFINE(BOOST_STRINGIZE(name));
98
104
struct
LoggerTimestamp
105
{
106
};
107
111
std::ostream&
112
operator<<
(std::ostream& os,
const
LoggerTimestamp
&);
113
114
#define NDN_LOG_TRACE(expression) NS_LOG_LOGIC(expression)
115
#define NDN_LOG_DEBUG(expression) NS_LOG_DEBUG(expression)
116
#define NDN_LOG_INFO(expression) NS_LOG_INFO(expression)
117
#define NDN_LOG_WARN(expression) NS_LOG_ERROR(expression)
118
#define NDN_LOG_ERROR(expression) NS_LOG_WARN(expression)
119
#define NDN_LOG_FATAL(expression) NS_LOG_FATAL(expression)
120
121
}
// namespace util
122
}
// namespace ndn
123
124
#endif // HAVE_NDN_CXX_CUSTOM_LOGGER
125
126
#endif // NDN_UTIL_LOGGER_HPP
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::util::LogLevel::TRACE
trace messages (most verbose)
ndn::util::LogLevel::DEBUG
debug messages
ndn::util::LogLevel::ERROR
serious error messages
ndn::util::LoggerTimestamp
a tag that writes a timestamp upon stream output
Definition:
logger.hpp:104
ndn::util::Logger::isLevelEnabled
bool isLevelEnabled(LogLevel level) const
Definition:
logger.hpp:79
ndn::util::LogLevel::INFO
informational messages
ndn::util::LogLevel
LogLevel
indicates the severity level of a log message
Definition:
logger.hpp:40
ndn::util::LogLevel::ALL
all messages
ndn::util::parseLogLevel
LogLevel parseLogLevel(const std::string &s)
parse LogLevel from string
Definition:
logger.cpp:59
ndn::util::LogLevel::WARN
warning messages
ndn::util::Logger::getModuleName
const std::string & getModuleName() const
Definition:
logger.hpp:73
ndn::util::operator<<
std::ostream & operator<<(std::ostream &os, Digest< Hash > &digest)
Definition:
digest.cpp:160
ndn::util::Logger
represents a logger in logging facility
Definition:
logger.hpp:66
ndn::util::LogLevel::FATAL
fatal (will be logged unconditionally)
ndn::util::LogLevel::NONE
no messages
ndn::util::Logger::setLevel
void setLevel(LogLevel level)
Definition:
logger.hpp:85
ndn::name
Definition:
name-component.cpp:36
ndnSIM
ndn-cxx
src
util
logger.hpp
Generated on Wed Jan 11 2017 18:17:15 for ndnSIM by
1.8.13