NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
logger.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #include "logger.hpp"
23 
24 #include "time.hpp"
25 
26 #include <cinttypes>
27 #include <stdio.h>
28 #include <type_traits>
29 
30 namespace ndn {
31 namespace util {
32 
33 std::ostream&
34 operator<<(std::ostream& os, LogLevel level)
35 {
36  switch (level) {
37  case LogLevel::FATAL:
38  return os << "FATAL";
39  case LogLevel::NONE:
40  return os << "NONE";
41  case LogLevel::ERROR:
42  return os << "ERROR";
43  case LogLevel::WARN:
44  return os << "WARN";
45  case LogLevel::INFO:
46  return os << "INFO";
47  case LogLevel::DEBUG:
48  return os << "DEBUG";
49  case LogLevel::TRACE:
50  return os << "TRACE";
51  case LogLevel::ALL:
52  return os << "ALL";
53  }
54 
55  BOOST_THROW_EXCEPTION(std::invalid_argument("unknown log level " + to_string(static_cast<int>(level))));
56 }
57 
59 parseLogLevel(const std::string& s)
60 {
61  if (s == "FATAL")
62  return LogLevel::FATAL;
63  else if (s == "NONE")
64  return LogLevel::NONE;
65  else if (s == "ERROR")
66  return LogLevel::ERROR;
67  else if (s == "WARN")
68  return LogLevel::WARN;
69  else if (s == "INFO")
70  return LogLevel::INFO;
71  else if (s == "DEBUG")
72  return LogLevel::DEBUG;
73  else if (s == "TRACE")
74  return LogLevel::TRACE;
75  else if (s == "ALL")
76  return LogLevel::ALL;
77 
78  BOOST_THROW_EXCEPTION(std::invalid_argument("unrecognized log level '" + s + "'"));
79 }
80 
81 Logger::Logger(const std::string& name)
82  : m_moduleName(name)
83 {
84 
85 }
86 
87 } // namespace util
88 } // namespace ndn
Copyright (c) 2011-2015 Regents of the University of California.
trace messages (most verbose)
serious error messages
informational messages
LogLevel
indicates the severity level of a log message
Definition: logger.hpp:40
LogLevel parseLogLevel(const std::string &s)
parse LogLevel from string
Definition: logger.cpp:59
Logger(const std::string &name)
Definition: logger.cpp:81
warning messages
std::ostream & operator<<(std::ostream &os, Digest< Hash > &digest)
Definition: digest.cpp:160
fatal (will be logged unconditionally)
std::string to_string(const V &v)
Definition: backports.hpp:51