]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Tidy
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 6 Sep 2024 12:40:20 +0000 (14:40 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 6 Sep 2024 12:40:20 +0000 (14:40 +0200)
pdns/recursordist/testrunner.cc

index 125cacd8314ee544e9045fe64063a6efec61d538..95c37f41edeb14bf5d45380d6a3c07c23cb89b74 100644 (file)
@@ -28,6 +28,7 @@
 #endif
 #include <boost/test/unit_test.hpp>
 
+#include <array>
 #include <iostream>
 #include <dnsrecords.hh>
 #include <iomanip>
 
 static std::string s_timestampFormat = "%s";
 
-static 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", static_cast<long long>(tv.tv_sec));
-  }
-
-  snprintf(buf + len, sz - len, ".%03ld", static_cast<long>(tv.tv_usec) / 1000);
-  return buf;
-}
-
 static void loggerBackend(const Logging::Entry& entry)
 {
   static thread_local std::stringstream buf;
@@ -65,17 +53,17 @@ static void loggerBackend(const Logging::Entry& entry)
     buf << " subsystem=" << std::quoted(entry.name.get());
   }
   buf << " level=" << entry.level;
-  if (entry.d_priority) {
+  if (entry.d_priority != 0) {
     buf << " prio=" << static_cast<int>(entry.d_priority);
   }
-  char timebuf[64];
-  buf << " ts=" << std::quoted(toTimestampStringMilli(entry.d_timestamp, timebuf, sizeof(timebuf)));
-  for (auto const& v : entry.values) {
+  std::array<char, 64> timebuf{};
+  buf << " ts=" << std::quoted(Logging::toTimestampStringMilli(entry.d_timestamp, timebuf));
+  for (auto const& val : entry.values) {
     buf << " ";
-    buf << v.first << "=" << std::quoted(v.second);
+    buf << val.first << "=" << std::quoted(val.second);
   }
-  Logger::Urgency u = entry.d_priority ? Logger::Urgency(entry.d_priority) : Logger::Info;
-  g_log << u << buf.str() << endl;
+  Logger::Urgency urgency = entry.d_priority != 0 ? Logger::Urgency(entry.d_priority) : Logger::Info;
+  g_log << urgency << buf.str() << endl;
 }
 
 static bool init_unit_test()