28 #ifdef HAVE_CUSTOM_LOGGER 29 #error "This file should not be compiled when custom logger is used" 35 #include <type_traits> 37 #include <ndn-cxx/util/time.hpp> 43 , m_enabledLogLevel(level)
50 using namespace ndn::time;
52 const auto sinceEpoch = system_clock::now().time_since_epoch();
53 BOOST_ASSERT(sinceEpoch.count() >= 0);
55 const auto usecs = std::abs(duration_cast<microseconds>(sinceEpoch).count());
56 const auto usecsPerSec = microseconds::period::den;
59 char buffer[10 + 1 + 6 + 1];
60 BOOST_ASSERT_MSG(usecs / usecsPerSec <= 9999999999,
"whole seconds cannot fit in 10 characters");
62 static_assert(std::is_same<microseconds::rep, int_least64_t>::value,
63 "PRIdLEAST64 is incompatible with microseconds::rep");
65 ::snprintf(buffer,
sizeof(buffer),
"%" PRIdLEAST64
".%06" PRIdLEAST64,
66 usecs / usecsPerSec, usecs % usecsPerSec);
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