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 '" + name +
"' is invalid"));
119 const auto sinceEpoch = system_clock::now().time_since_epoch();
120 BOOST_ASSERT(sinceEpoch.count() >= 0);
122 const auto usecs =
std::abs(duration_cast<microseconds>(sinceEpoch).count());
123 const auto usecsPerSec = microseconds::period::den;
126 char buffer[10 + 1 + 6 + 1];
127 BOOST_ASSERT_MSG(usecs / usecsPerSec <= 9999999999,
"whole seconds cannot fit in 10 characters");
129 static_assert(std::is_same<microseconds::rep, int_least64_t>::value,
130 "PRIdLEAST64 is incompatible with microseconds::rep");
132 ::snprintf(buffer,
sizeof(buffer),
"%" PRIdLEAST64
".%06" PRIdLEAST64,
133 usecs / usecsPerSec, usecs % usecsPerSec);
static void addLogger(Logger &logger)
register a new logger
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 string
a tag that writes a timestamp upon stream output
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 string
Logger(const std::string &name)
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)