NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: 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; -*- */
2 /*
3  * Copyright (c) 2013-2019 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_UTIL_LOGGER_HPP
23 #define NDN_UTIL_LOGGER_HPP
24 
25 #include "ns3/log.h"
26 
27 namespace ndn {
28 namespace util {
29 
32 enum class LogLevel {
33  FATAL = -1,
34  NONE = 0,
35  ERROR = 1,
36  WARN = 2,
37  INFO = 3,
38  DEBUG = 4,
39  TRACE = 5,
40  ALL = 255
41 };
42 
46 std::ostream&
47 operator<<(std::ostream& os, LogLevel level);
48 
53 parseLogLevel(const std::string& s);
54 
55 namespace detail {
56 
58 template<class T>
59 struct ExtractArgument;
60 
61 template<class T, class U>
62 struct ExtractArgument<T(U&)>
63 {
64  using type = U;
65 };
66 
67 template<class T, class U>
68 struct ExtractArgument<T(U)&>
69 {
70  using type = U;
71 };
72 
73 template<class T>
74 using ArgumentType = typename ExtractArgument<T>::type;
77 } // namespace detail
78 
81 #define NDN_LOG_INIT(name) NS_LOG_COMPONENT_DEFINE("ndn-cxx." BOOST_STRINGIZE(name))
82 
83 #define NDN_LOG_MEMBER_DECL() \
84  static ::ns3::LogComponent g_log
85 
86 #define NDN_LOG_MEMBER_INIT(cls, name) \
87  ::ns3::LogComponent cls::g_log = ::ns3::LogComponent("ndn-cxx." BOOST_STRINGIZE(name), __FILE__)
88 
89 // ::ns3::LogComponent ::ndn::util::detail::ArgumentType<void(cls)>::g_log = ::ns3::LogComponent("ndn-cxx." BOOST_STRINGIZE(name), __FILE__)
90 
91 #define NDN_LOG_MEMBER_DECL_SPECIALIZED(cls) \
92  static ::ns3::LogComponent g_log
93 
94 #define NDN_LOG_MEMBER_INIT_SPECIALIZED(cls, name) \
95  template<> \
96  ::ns3::LogComponent ::ndn::util::detail::ArgumentType<void(cls)>::g_log = ::ns3::LogComponent("ndn-cxx." BOOST_STRINGIZE(name), __FILE__)
97 
98 #define NDN_LOG_TRACE(expression) NS_LOG_LOGIC(expression)
99 #define NDN_LOG_DEBUG(expression) NS_LOG_DEBUG(expression)
100 #define NDN_LOG_INFO(expression) NS_LOG_INFO(expression)
101 #define NDN_LOG_WARN(expression) NS_LOG_ERROR(expression)
102 #define NDN_LOG_ERROR(expression) NS_LOG_WARN(expression)
103 #define NDN_LOG_FATAL(expression) NS_LOG_FATAL(expression)
104 
105 } // namespace util
106 } // namespace ndn
107 
108 #endif // NDN_UTIL_LOGGER_HPP
ndn::util::LogLevel::WARN
@ WARN
warning messages
ndn::util::LogLevel::ERROR
@ ERROR
serious error messages
ndn::util::LogLevel::NONE
@ NONE
no messages
ndn::util::operator<<
std::ostream & operator<<(std::ostream &os, LogLevel level)
Output LogLevel as a string.
Definition: logger.cpp:29
ndn::util::parseLogLevel
LogLevel parseLogLevel(const std::string &s)
Parse LogLevel from a string.
Definition: logger.cpp:54
ndn::util::LogLevel::FATAL
@ FATAL
fatal (will be logged unconditionally)
ndn::util::LogLevel
LogLevel
Indicates the severity level of a log message.
Definition: logger.hpp:32
ndn::util::LogLevel::ALL
@ ALL
all messages
ndn::util::LogLevel::TRACE
@ TRACE
trace messages (most verbose)
ndn::util::LogLevel::DEBUG
@ DEBUG
debug messages
ndn::util::LogLevel::INFO
@ INFO
informational messages
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34