56 NDN_THROW(std::invalid_argument(
"unknown log level " +
to_string(static_cast<int>(level))));
66 else if (s ==
"ERROR")
72 else if (s ==
"DEBUG")
74 else if (s ==
"TRACE")
79 NDN_THROW(std::invalid_argument(
"unrecognized log level '" + s +
"'"));
90 const char* okChars =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~#%_<>.-";
91 if (std::strspn(name.c_str(), okChars) != name.size()) {
94 if (name.empty() || name.front() ==
'.' || name.back() ==
'.') {
97 if (name.find(
"..") != std::string::npos) {
107 NDN_THROW(std::invalid_argument(
"Logger name '" + m_moduleName +
"' is invalid"));
110 Logging::get().addLoggerImpl(*
this);
116 std::string moduleName(name);
118 NDN_THROW(std::invalid_argument(
"Logger name '" + moduleName +
"' is invalid"));
120 Logging::get().registerLoggerNameImpl(
std::move(moduleName));
130 const auto sinceEpoch = system_clock::now().time_since_epoch();
131 BOOST_ASSERT(sinceEpoch.count() >= 0);
133 const auto usecs =
std::abs(duration_cast<microseconds>(sinceEpoch).count());
134 const auto usecsPerSec = microseconds::period::den;
137 char buffer[10 + 1 + 6 + 1];
138 BOOST_ASSERT_MSG(usecs / usecsPerSec <= 9999999999,
"whole seconds cannot fit in 10 characters");
140 static_assert(std::is_same<microseconds::rep, int_least64_t>::value,
141 "PRIdLEAST64 is incompatible with microseconds::rep");
143 ::snprintf(buffer,
sizeof(buffer),
"%" PRIdLEAST64
".%06" PRIdLEAST64,
144 usecs / usecsPerSec, usecs % usecsPerSec);
trace messages (most verbose)
std::ostream & operator<<(std::ostream &os, LogLevel level)
Output LogLevel as a string.
static void registerModuleName(const char *name)
constexpr duration< Rep, Period > abs(duration< Rep, Period > d)
LogLevel
Indicates the severity level of a log message.
LogLevel parseLogLevel(const std::string &s)
Parse LogLevel from a string.
A tag type used to output a timestamp to a stream.
static bool isValidLoggerName(const std::string &name)
checks if incoming logger name meets criteria
fatal (will be logged unconditionally)
std::string to_string(const V &v)
void setLevel(LogLevel level)