57 BOOST_THROW_EXCEPTION(std::invalid_argument(
"unknown log level " +
to_string(static_cast<int>(level))));
67 else if (s ==
"ERROR")
73 else if (s ==
"DEBUG")
75 else if (s ==
"TRACE")
80 BOOST_THROW_EXCEPTION(std::invalid_argument(
"unrecognized log level '" + s +
"'"));
91 const char* okChars =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~#%_<>.-";
92 if (std::strspn(name.c_str(), okChars) != name.size()) {
95 if (name.empty() || name.front() ==
'.' || name.back() ==
'.') {
98 if (name.find(
"..") != std::string::npos) {
108 BOOST_THROW_EXCEPTION(std::invalid_argument(
"Logger name '" + m_moduleName +
"' is invalid"));
111 Logging::get().addLoggerImpl(*
this);
117 std::string moduleName(name);
119 BOOST_THROW_EXCEPTION(std::invalid_argument(
"Logger name '" + moduleName +
"' is invalid"));
121 Logging::get().registerLoggerNameImpl(std::move(moduleName));
131 const auto sinceEpoch = system_clock::now().time_since_epoch();
132 BOOST_ASSERT(sinceEpoch.count() >= 0);
134 const auto usecs =
std::abs(duration_cast<microseconds>(sinceEpoch).count());
135 const auto usecsPerSec = microseconds::period::den;
138 char buffer[10 + 1 + 6 + 1];
139 BOOST_ASSERT_MSG(usecs / usecsPerSec <= 9999999999,
"whole seconds cannot fit in 10 characters");
141 static_assert(std::is_same<microseconds::rep, int_least64_t>::value,
142 "PRIdLEAST64 is incompatible with microseconds::rep");
144 ::snprintf(buffer,
sizeof(buffer),
"%" PRIdLEAST64
".%06" PRIdLEAST64,
145 usecs / usecsPerSec, usecs % usecsPerSec);
Copyright (c) 2013-2017 Regents of the University of California.
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)