]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Reformat 10483/head
authorOtto <otto.moerbeek@open-xchange.com>
Fri, 16 Apr 2021 13:30:15 +0000 (15:30 +0200)
committerOtto <otto.moerbeek@open-xchange.com>
Tue, 8 Jun 2021 08:20:27 +0000 (10:20 +0200)
.not-formatted
pdns/logger.cc
pdns/logger.hh

index 452069f38639a188938010eff28231948e67edc7..1ff59d93acbca56f47209396527d697333f0ba83 100644 (file)
 ./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
index 7d920f576f2579f72d40dd3e8671b48ab4227bdf..c2a2de2cac98cd524394d2ac095df3a71a67362c 100644 (file)
@@ -50,116 +50,113 @@ Logger& getLogger()
   return log;
 }
 
-void Logger::log(const string &msg, Urgency u) noexcept
+void Logger::log(const stringmsg, 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<std::mutex> l(m); // the C++-2011 spec says we need this, and OSX actually does
-    clog << string(buffer) + prefix + msg <<endl;
+    clog << string(buffer) + prefix + msg << endl;
 #ifndef RECURSOR
-    mustAccount=true;
+    mustAccount = true;
 #endif
   }
-  if( u <= d_loglevel && !d_disableSyslog ) {
-    syslog(u,"%s",msg.c_str());
+  if (u <= d_loglevel && !d_disableSyslog) {
+    syslog(u, "%s", msg.c_str());
 #ifndef RECURSOR
-    mustAccount=true;
+    mustAccount = true;
 #endif
   }
 
 #ifndef RECURSOR
-  if(mustAccount) {
-      try {
-        S.ringAccount("logmessages",msg);
-      }
-      catch (const runtime_error& e) {
-        cerr << e.what() << endl;
-      }
+  if (mustAccount) {
+    try {
+      S.ringAccount("logmessages", msg);
+    }
+    catch (const runtime_error& e) {
+      cerr << e.what() << endl;
+    }
   }
 #endif
 }
 
-void Logger::setLoglevel( Urgency u )
+void Logger::setLoglevel(Urgency u)
 {
   d_loglevel = u;
 }
-  
 
 void Logger::toConsole(Urgency u)
 {
-  consoleUrgency=u;
+  consoleUrgency = u;
 }
 
 void Logger::open()
 {
-  if(opened)
+  if (opened)
     closelog();
-  openlog(name.c_str(),flags,d_facility);
-  opened=true;
+  openlog(name.c_str(), flags, d_facility);
+  opened = true;
 }
 
-void Logger::setName(const string &_name)
+void Logger::setName(const string_name)
 {
-  name=_name;
+  name = _name;
   open();
 }
 
 Logger::Logger(string n, int facility) :
-  name(std::move(n)), flags(LOG_PID|LOG_NDELAY), d_facility(facility), d_loglevel(Logger::None),
-  consoleUrgency(Error), opened(false), d_disableSyslog(false)
+  name(std::move(n)), flags(LOG_PID | LOG_NDELAY), d_facility(facility), d_loglevel(Logger::None), consoleUrgency(Error), opened(false), d_disableSyslog(false)
 {
   open();
-
 }
 
 Logger& Logger::operator<<(Urgency u)
 {
-  getPerThread().d_urgency=u;
+  getPerThread().d_urgency = u;
   return *this;
 }
 
@@ -168,39 +165,38 @@ Logger::PerThread& Logger::getPerThread()
   return t_perThread;
 }
 
-Logger& Logger::operator<<(const string &s)
+Logger& Logger::operator<<(const strings)
 {
   PerThread& pt = getPerThread();
   pt.d_output.append(s);
   return *this;
 }
 
-Logger& Logger::operator<<(const char *s)
+Logger& Logger::operator<<(const chars)
 {
-  *this<<string(s);
+  *this << string(s);
   return *this;
 }
 
-Logger& Logger::operator<<(ostream & (&)(ostream &))
+Logger& Logger::operator<<(ostream& (&)(ostream&))
 {
   PerThread& pt = getPerThread();
 
   log(pt.d_output, pt.d_urgency);
   pt.d_output.clear();
-  pt.d_urgency=Info;
+  pt.d_urgency = Info;
   return *this;
 }
 
-Logger& Logger::operator<<(const DNSName &d)
+Logger& Logger::operator<<(const DNSNamed)
 {
-  *this<<d.toLogString();
+  *this << d.toLogString();
 
   return *this;
 }
 
-Logger& Logger::operator<<(const ComboAddress &ca)
+Logger& Logger::operator<<(const ComboAddressca)
 {
-  *this<<ca.toLogString();
+  *this << ca.toLogString();
   return *this;
 }
-
index 5160c8f4aaf5789170e6b6848aa9752633b3a35a..dc86efbcd7977bb6b38cbc58e1c35854f86a11cb 100644 (file)
 class Logger
 {
 public:
-  Logger(string , int facility=LOG_DAEMON); //!< pass the identification you wish to appear in the log
+  Logger(string, int facility = LOG_DAEMON); //!< pass the identification you wish to appear in the log
 
   //! The urgency of a log message
-  enum Urgency {All=32767,Alert=LOG_ALERT, Critical=LOG_CRIT, Error=LOG_ERR, Warning=LOG_WARNING,
-                Notice=LOG_NOTICE,Info=LOG_INFO, Debug=LOG_DEBUG, None=-1};
+  enum Urgency
+  {
+    All = 32767,
+    Alert = LOG_ALERT,
+    Critical = LOG_CRIT,
+    Error = LOG_ERR,
+    Warning = LOG_WARNING,
+    Notice = LOG_NOTICE,
+    Info = LOG_INFO,
+    Debug = LOG_DEBUG,
+    None = -1
+  };
 
   /** Log a message.
       \param msg Message you wish to log
       \param u Urgency of the message you wish to log
   */
-  void log(const string &msg, Urgency u=Notice) noexcept;
+  void log(const string& msg, Urgency u = Notice) noexcept;
 
-  void setFacility(int f){d_facility=f;open();} //!< Choose logging facility
-  void setFlag(int f){flags|=f;open();} //!< set a syslog flag
-  void setName(const string &);
+  void setFacility(int f)
+  {
+    d_facility = f;
+    open();
+  } //!< Choose logging facility
+  void setFlag(int f)
+  {
+    flags |= f;
+    open();
+  } //!< set a syslog flag
+  void setName(const string&);
 
   //! set lower limit of urgency needed for console display. Messages of this urgency, and higher, will be displayed
   void toConsole(Urgency);
-  void setLoglevel( Urgency );
+  void setLoglevel(Urgency);
 
-  void disableSyslog(bool d) {
+  void disableSyslog(bool d)
+  {
     d_disableSyslog = d;
   }
 
-  void setTimestamps(bool t) {
+  void setTimestamps(bool t)
+  {
     d_timestamps = t;
   }
 
-  void setPrefixed(bool p) {
+  void setPrefixed(bool p)
+  {
     d_prefixed = p;
   }
 
   //! Log to a file.
-  void toFile( const string & filename );
+  void toFile(const string& filename);
 
-  void resetFlags(){flags=0;open();} //!< zero the flags
+  void resetFlags()
+  {
+    flags = 0;
+    open();
+  } //!< zero the flags
   /** Use this to stream to your log, like this:
       \code
       g_log<<"This is an informational message"<<endl; // logged at default loglevel (Info)
@@ -78,11 +103,11 @@ public:
       g_log<<"This is an informational message"<<endl; // logged AGAIN at default loglevel (Info)
       \endcode
   */
-  Logger& operator<<(const char *s);
-  Logger& operator<<(const string &s);   //!< log a string
+  Logger& operator<<(const chars);
+  Logger& operator<<(const string& s); //!< log a string
   Logger& operator<<(const DNSName&);
   Logger& operator<<(const ComboAddress&); //!< log an address
-  Logger& operator<<(Urgency);    //!< set the urgency, << style
+  Logger& operator<<(Urgency); //!< set the urgency, << style
 
   Logger& operator<<(const QType& qtype)
   {
@@ -97,19 +122,22 @@ public:
   }
 
   // Using const & since otherwise SyncRes:: values induce (illegal) copies
-  template<typename T> Logger & operator<<(const T& i) {
+  template <typename T>
+  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;