From: Otto Moerbeek Date: Fri, 6 Sep 2024 12:40:20 +0000 (+0200) Subject: Tidy X-Git-Tag: rec-5.2.0-alpha1~91^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48dde7333919cf2061a307ce4a1211029d3a0ff7;p=thirdparty%2Fpdns.git Tidy --- diff --git a/pdns/recursordist/testrunner.cc b/pdns/recursordist/testrunner.cc index 125cacd831..95c37f41ed 100644 --- a/pdns/recursordist/testrunner.cc +++ b/pdns/recursordist/testrunner.cc @@ -28,6 +28,7 @@ #endif #include +#include #include #include #include @@ -38,19 +39,6 @@ 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(tv.tv_sec)); - } - - snprintf(buf + len, sz - len, ".%03ld", static_cast(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(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 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()