]> granicus.if.org Git - pdns/commitdiff
Fix logger time_t issues on at least OpenBSD.
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Thu, 3 Jan 2019 10:59:04 +0000 (11:59 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Thu, 3 Jan 2019 11:25:02 +0000 (12:25 +0100)
Use a template to log trivial types. This way the compiler figures
out what logger methods oo generate.

pdns/logger.cc
pdns/logger.hh

index 1766d35ae9a74aa52218bdbd2ead3a2511271f19..cd56e5d78d771b285d2bd60dcdaed828124e331f 100644 (file)
@@ -184,64 +184,6 @@ Logger& Logger::operator<<(const char *s)
   return *this;
 }
 
-Logger& Logger::operator<<(int i)
-{
-  ostringstream tmp;
-  tmp<<i;
-
-  *this<<tmp.str();
-
-  return *this;
-}
-
-Logger& Logger::operator<<(double i)
-{
-  ostringstream tmp;
-  tmp<<i;
-  *this<<tmp.str();
-  return *this;
-}
-
-Logger& Logger::operator<<(unsigned int i)
-{
-  ostringstream tmp;
-  tmp<<i;
-
-  *this<<tmp.str();
-
-  return *this;
-}
-
-Logger& Logger::operator<<(unsigned long i)
-{
-  ostringstream tmp;
-  tmp<<i;
-
-  *this<<tmp.str();
-
-  return *this;
-}
-
-Logger& Logger::operator<<(unsigned long long i)
-{
-  ostringstream tmp;
-  tmp<<i;
-
-  *this<<tmp.str();
-
-  return *this;
-}
-
-Logger& Logger::operator<<(long i)
-{
-  ostringstream tmp;
-  tmp<<i;
-
-  *this<<tmp.str();
-
-  return *this;
-}
-
 Logger& Logger::operator<<(ostream & (&)(ostream &))
 {
   PerThread* pt =getPerThread();
index 3fb97ee0fcf9ec8f079b3e6cd5d5a5929100efce..df0907eb9e6443ea1694a3179e7a0c6b3e4de6a2 100644 (file)
@@ -81,16 +81,18 @@ public:
   */
   Logger& operator<<(const char *s);
   Logger& operator<<(const string &s);   //!< log a string
-  Logger& operator<<(int);   //!< log an int
-  Logger& operator<<(double);   //!< log a double
-  Logger& operator<<(unsigned int);   //!< log an unsigned int
-  Logger& operator<<(long);   //!< log an unsigned int
-  Logger& operator<<(unsigned long);   //!< log an unsigned int
-  Logger& operator<<(unsigned long long);   //!< log an unsigned 64 bit int
   Logger& operator<<(const DNSName&); 
   Logger& operator<<(const ComboAddress&); //!< log an address
   Logger& operator<<(Urgency);    //!< set the urgency, << style
 
+  // Using const & since otherwise SyncRes:: values induce (illegal) copies
+  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
 
 private: