]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add a disable-syslog setting 3850/head
authorPieter Lexis <pieter.lexis@powerdns.com>
Tue, 15 Mar 2016 10:51:43 +0000 (11:51 +0100)
committerPieter Lexis <pieter.lexis@powerdns.com>
Wed, 11 May 2016 13:21:22 +0000 (15:21 +0200)
This allows the use of e.g. the `Type=simple` in systemd and prevents
the double logging issue.

pdns/common_startup.cc
pdns/logger.cc
pdns/logger.hh
pdns/pdns.conf-dist
pdns/pdns_recursor.cc
pdns/receiver.cc

index 45ab21dc06217a3aa8de96ce96af0afdadb16d48..b9c2165de5f622c76b4ebfcbfde42940296764d8 100644 (file)
@@ -78,6 +78,7 @@ void declareArguments()
   ::arg().set("version-string","PowerDNS version in packets - full, anonymous, powerdns or custom")="full"; 
   ::arg().set("control-console","Debugging switch - don't use")="no"; // but I know you will!
   ::arg().set("loglevel","Amount of logging. Higher is more. Do not set below 3")="4";
+  ::arg().set("disable-syslog","Disable logging to syslog, useful when running inside a supervisor that logs stdout")="no";
   ::arg().set("default-soa-name","name to insert in the SOA record if none set in the backend")="a.misconfigured.powerdns.server";
   ::arg().set("default-soa-mail","mail address to insert in the SOA record if none set in the backend")="";
   ::arg().set("distributor-threads","Default number of Distributor (backend) threads to start")="3";
index 5e6fd2b8b0d171e6addf1cb906f742184b001444..6357bffa62b8bc8a0e6899cb05dbbb6cb295f1dd 100644 (file)
@@ -50,7 +50,7 @@ void Logger::log(const string &msg, Urgency u)
     clog<<buffer;
     clog <<msg <<endl;
   }
-  if( u <= d_loglevel ) {
+  if( u <= d_loglevel && !d_disableSyslog ) {
 #ifndef RECURSOR
     S.ringAccount("logmessages",msg);
 #endif
index 2c3b4496366546261e4899b3506bc5f8bc23392e..4a52a5005c8fa35acc4ac26c0c255a8eba19375b 100644 (file)
@@ -58,6 +58,10 @@ public:
   void toConsole(Urgency);
   void setLoglevel( Urgency );
 
+  void disableSyslog(bool d) {
+    d_disableSyslog = d;
+  }
+
   //! Log to a file.
   void toFile( const string & filename );
   
@@ -91,6 +95,7 @@ private:
   Urgency d_loglevel;
   Urgency consoleUrgency;
   pthread_mutex_t lock;
+  bool d_disableSyslog;
 };
 
 extern Logger &theL(const string &pname="");
index 8ba6ce13e90fef3a8dfab340d15f978848beb8c1..b9c0bd2ee08708fecdbf7e26d391ba6f79084e06 100644 (file)
 #
 # disable-axfr-rectify=no
 
+#################################
+# disable-syslog       Disable logging to syslog, useful when running inside a supervisor that logs stdout
+#
+# disable-syslog=no
+
 #################################
 # disable-tcp  Do not listen to TCP queries
 #
index 3c4efdf5899da7ca43fdf5502d6b66c3d987cf5d..79e5e5a267e417f32b2f678ec4eb56bf00ea1144 100644 (file)
@@ -1749,6 +1749,7 @@ int serviceMain(int argc, char*argv[])
   L.setName(s_programname);
 
   L.setLoglevel((Logger::Urgency)(6)); // info and up
+  L.disableSyslog(::arg().mustDo("disable-syslog"));
 
   if(!::arg()["logging-facility"].empty()) {
     int val=logFacilityToLOG(::arg().asNum("logging-facility") );
@@ -2086,6 +2087,7 @@ int main(int argc, char **argv)
     ::arg().set("trace","if we should output heaps of logging. set to 'fail' to only log failing domains")="off";
     ::arg().set("daemon","Operate as a daemon")="yes";
     ::arg().set("loglevel","Amount of logging. Higher is more. Do not set below 3")="4";
+    ::arg().set("disable-syslog","Disable logging to syslog, useful when running inside a supervisor that logs stdout")="no";
     ::arg().set("log-common-errors","If we should log rather common errors")="yes";
     ::arg().set("chroot","switch to chroot jail")="";
     ::arg().set("setgid","If set, change group id to this gid for more security")="";
index a2f559165dfc57280c3ed7fa14eb995967fa2958..22257b9a6c91fd7a37cc91959e84221b24d4deff 100644 (file)
@@ -450,6 +450,7 @@ int main(int argc, char **argv)
     }
 
     L.setLoglevel((Logger::Urgency)(::arg().asNum("loglevel")));
+    L.disableSyslog(::arg().mustDo("disable-syslog"));
     L.toConsole((Logger::Urgency)(::arg().asNum("loglevel")));  
 
     if(::arg().mustDo("help") || ::arg().mustDo("config")) {