return 0;
}
+//static std::string s_timestampFormat = "%m-%dT%H:%M:%S";
+static std::string s_timestampFormat = "%s";
+const char* toTimestampStringMilli(const struct timeval& tv, char *buf, size_t sz)
+{
+ struct tm tm;
+ size_t len = strftime(buf, sz, s_timestampFormat.c_str(), localtime_r(&tv.tv_sec, &tm));
+ if (len == 0) {
+ len = snprintf(buf, sz, "%lld", (long long) tv.tv_sec);
+ }
+
+ snprintf(buf + len, sz - len, ".%03ld", tv.tv_usec / 1000);
+ return buf;
+}
static void loggerBackend(const Logging::Entry& entry) {
static thread_local std::stringstream buf;
if (entry.name) {
buf << " subsystem=" << std::quoted(entry.name.get());
}
-
+ char timebuf[64];
+ buf << " ts=" << std::quoted(toTimestampStringMilli(entry.d_timestamp, timebuf, sizeof(timebuf)));
for (auto const& v: entry.values) {
buf << " ";
buf << v.first << "=" << std::quoted(v.second);
boost::optional<std::string> name; // name parts joined with '.'
std::string message; // message as send to log call
boost::optional<std::string> error; // error if .Error() was called
+ struct timeval d_timestamp;
std::map<std::string, std::string> values;
};