29 #include <type_traits>
56 BOOST_THROW_EXCEPTION(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 BOOST_THROW_EXCEPTION(std::invalid_argument(
"unrecognized log level '" + s +
"'"));
94 static const microseconds::rep ONE_SECOND = 1000000;
95 microseconds::rep usecs = duration_cast<microseconds>(
96 system_clock::now().time_since_epoch()).count();
99 char buffer[10 + 1 + 6 + 1];
100 BOOST_ASSERT_MSG(usecs / ONE_SECOND <= 9999999999L,
101 "whole seconds cannot fit in 10 characters");
103 static_assert(std::is_same<microseconds::rep, int_least64_t>::value,
104 "PRIdLEAST64 is incompatible with microseconds::rep");
106 snprintf(buffer,
sizeof(buffer),
"%" PRIdLEAST64
".%06" PRIdLEAST64,
107 usecs / ONE_SECOND, usecs % ONE_SECOND);
static void addLogger(Logger &logger)
register a new logger
Copyright (c) 2013-2016 Regents of the University of California.
trace messages (most verbose)
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)
std::ostream & operator<<(std::ostream &os, Digest< Hash > &digest)
fatal (will be logged unconditionally)
std::string to_string(const V &v)
void setLevel(LogLevel level)