From: Otto Date: Fri, 16 Apr 2021 13:30:15 +0000 (+0200) Subject: Reformat X-Git-Tag: dnsdist-1.7.0-alpha1~146^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F10483%2Fhead;p=thirdparty%2Fpdns.git Reformat --- diff --git a/.not-formatted b/.not-formatted index 452069f386..1ff59d93ac 100644 --- a/.not-formatted +++ b/.not-formatted @@ -197,8 +197,6 @@ ./pdns/libssl.cc ./pdns/libssl.hh ./pdns/lock.hh -./pdns/logger.cc -./pdns/logger.hh ./pdns/lua-auth4.cc ./pdns/lua-auth4.hh ./pdns/lua-base4.cc diff --git a/pdns/logger.cc b/pdns/logger.cc index 7d920f576f..c2a2de2cac 100644 --- a/pdns/logger.cc +++ b/pdns/logger.cc @@ -50,116 +50,113 @@ Logger& getLogger() return log; } -void Logger::log(const string &msg, Urgency u) noexcept +void Logger::log(const string& msg, Urgency u) noexcept { #ifndef RECURSOR bool mustAccount(false); #endif - if(u<=consoleUrgency) { + if (u <= consoleUrgency) { char buffer[50] = ""; if (d_timestamps) { struct tm tm; time_t t; time(&t); localtime_r(&t, &tm); - strftime(buffer,sizeof(buffer),"%b %d %H:%M:%S ", &tm); + strftime(buffer, sizeof(buffer), "%b %d %H:%M:%S ", &tm); } string prefix; if (d_prefixed) { - switch(u) { - case All: - prefix = "[all] "; - break; - case Alert: - prefix = "[ALERT] "; - break; - case Critical: - prefix = "[CRITICAL] "; - break; - case Error: - prefix = "[ERROR] "; - break; - case Warning: - prefix = "[WARNING] "; - break; - case Notice: - prefix = "[NOTICE] "; - break; - case Info: - prefix = "[INFO] "; - break; - case Debug: - prefix = "[DEBUG] "; - break; - case None: - prefix = "[none] "; - break; + switch (u) { + case All: + prefix = "[all] "; + break; + case Alert: + prefix = "[ALERT] "; + break; + case Critical: + prefix = "[CRITICAL] "; + break; + case Error: + prefix = "[ERROR] "; + break; + case Warning: + prefix = "[WARNING] "; + break; + case Notice: + prefix = "[NOTICE] "; + break; + case Info: + prefix = "[INFO] "; + break; + case Debug: + prefix = "[DEBUG] "; + break; + case None: + prefix = "[none] "; + break; } } static std::mutex m; std::lock_guard l(m); // the C++-2011 spec says we need this, and OSX actually does - clog << string(buffer) + prefix + msg < Logger & operator<<(const T& i) { + template + Logger& operator<<(const T& i) + { ostringstream tmp; tmp << i; *this << tmp.str(); return *this; } - Logger& operator<<(std::ostream & (&)(std::ostream &)); //!< this is to recognise the endl, and to commit the log + Logger& operator<<(std::ostream& (&)(std::ostream&)); //!< this is to recognise the endl, and to commit the log private: struct PerThread { - PerThread() : d_urgency(Info) + PerThread() : + d_urgency(Info) {} string d_output; Urgency d_urgency;