34 if (path.empty() || path ==
"/dev/null") {
38 if (path ==
"/dev/stdout") {
39 os_ = std::make_unique<std::ostream>(std::cout.rdbuf());
42 if (path ==
"/dev/stderr") {
43 os_ = std::make_unique<std::ostream>(std::cerr.rdbuf());
47 os_ = std::make_unique<std::ofstream>(path.c_str());
49 die(
"Could not open json log output: " 50 << path <<
" : " << strerror(errno));
69 static std::ofstream dummy_of_;
78 << std::chrono::duration_cast<std::chrono::microseconds>(
79 std::chrono::system_clock::now().time_since_epoch()).count();
friend class JsonLine
friends for sending to os_
JsonLogger()=default
open JsonLogger with ofstream uninitialized to discard log output.
JsonLogger * super_
output to superior JsonLogger
#define die(msg)
Instead of std::terminate(), throw the output the message via an exception.
JsonLine line()
create new JsonLine instance which will be written to this logger.
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
JsonVerbatim common_
common items outputted to each line
std::unique_ptr< std::ostream > os_
direct output stream for top loggers
JsonLogger is a receiver of JSON output objects for logging.
JsonLine is an object used to aggregate a set of key:value pairs for output into a JSON log...