28 #ifdef HAVE_CUSTOM_LOGGER 29 #error "This file should not be compiled when custom logger is used" 32 #include <ndn-cxx/util/time.hpp> 35 #include <type_traits> 41 , m_enabledLogLevel(level)
48 using namespace ndn::time;
50 static const microseconds::rep ONE_SECOND = 1000000;
51 microseconds::rep microsecondsSinceEpoch = duration_cast<microseconds>(
52 system_clock::now().time_since_epoch()).count();
55 char buffer[10 + 1 + 6 + 1];
56 BOOST_ASSERT_MSG(microsecondsSinceEpoch / ONE_SECOND <= 9999999999L,
57 "whole seconds cannot fit in 10 characters");
59 static_assert(std::is_same<microseconds::rep, int_least64_t>::value,
60 "PRIdLEAST64 is incompatible with microseconds::rep");
63 snprintf(buffer,
sizeof(buffer),
"%" PRIdLEAST64
".%06" PRIdLEAST64,
64 microsecondsSinceEpoch / ONE_SECOND,
65 microsecondsSinceEpoch % ONE_SECOND);
a tag that writes a timestamp upon stream output
std::ostream & operator<<(std::ostream &os, const LoggerTimestamp &)
write a timestamp to os
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Logger(const std::string &name, LogLevel level)
LogLevel
indicates a log level