55 BOOST_THROW_EXCEPTION(std::invalid_argument(
"unknown log level " +
to_string(static_cast<int>(level))));
65 else if (s ==
"ERROR")
71 else if (s ==
"DEBUG")
73 else if (s ==
"TRACE")
78 BOOST_THROW_EXCEPTION(std::invalid_argument(
"unrecognized log level '" + s +
"'"));
89 const char* okChars =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~#%_<>.-";
90 if (std::strspn(name.c_str(), okChars) != name.size()) {
93 if (name.empty() || name.front() ==
'.' || name.back() ==
'.') {
96 if (name.find(
"..") != std::string::npos) {
106 BOOST_THROW_EXCEPTION(std::invalid_argument(
"Logger name " + name +
" is invalid"));
117 static const microseconds::rep ONE_SECOND = 1000000;
118 microseconds::rep usecs = duration_cast<microseconds>(
119 system_clock::now().time_since_epoch()).count();
122 char buffer[10 + 1 + 6 + 1];
123 BOOST_ASSERT_MSG(usecs / ONE_SECOND <= 9999999999L,
124 "whole seconds cannot fit in 10 characters");
126 static_assert(std::is_same<microseconds::rep, int_least64_t>::value,
127 "PRIdLEAST64 is incompatible with microseconds::rep");
129 snprintf(buffer,
sizeof(buffer),
"%" PRIdLEAST64
".%06" PRIdLEAST64,
130 usecs / ONE_SECOND, usecs % ONE_SECOND);
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
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)