]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add setting to switch to non-structed logging
authorOtto <otto.moerbeek@open-xchange.com>
Tue, 12 Oct 2021 10:19:55 +0000 (12:19 +0200)
committerOtto <otto.moerbeek@open-xchange.com>
Tue, 12 Oct 2021 12:00:22 +0000 (14:00 +0200)
pdns/pdns_recursor.cc
pdns/recursordist/docs/settings.rst
pdns/recursordist/docs/upgrade.rst
pdns/recursordist/logging.cc
pdns/recursordist/logging.hh

index e8781acebe6f46b65e893aafbb4b61ad44e0b760..7a705872808f4c1314a2ca1837822dd3f364daa4 100644 (file)
@@ -4770,6 +4770,8 @@ static int serviceMain(int argc, char*argv[])
 {
   int ret = EXIT_SUCCESS;
 
+  g_slogStructured = ::arg().mustDo("structured-logging");
+
   g_log.setName(s_programname);
   g_log.disableSyslog(::arg().mustDo("disable-syslog"));
   g_log.setTimestamps(::arg().mustDo("log-timestamp"));
@@ -5697,6 +5699,7 @@ static void loggerBackend(const Logging::Entry& entry) {
   g_log << u << buf.str() << endl;
 }
 
+
 int main(int argc, char **argv)
 {
   g_argc = argc;
@@ -5946,6 +5949,7 @@ int main(int argc, char **argv)
     ::arg().set("tcp-out-max-idle-per-auth", "Maximum number of idle TCP/DoT connections to a specific IP per thread, 0 means do not keep idle connections open") = "10";
     ::arg().set("tcp-out-max-queries", "Maximum total number of queries per TCP/DoT connection, 0 means no limit") = "0";
     ::arg().set("tcp-out-max-idle-per-thread", "Maximum number of idle TCP/DoT connections per thread") = "100";
+    ::arg().setSwitch("structured-logging", "Prefer structured logging") = "yes";
 
     ::arg().setCmd("help","Provide a helpful message");
     ::arg().setCmd("version","Print version string");
index eab06acac582d56240571a256cab8b14d3463122..959388acddefcd2f10e4ebe6b983423f0ad3420e 100644 (file)
@@ -1864,6 +1864,17 @@ Can be read out using ``rec_control top-remotes``.
 
 A list of comma-separated statistic names, that are prevented from being exported via SNMP, for performance reasons.
 
+.. _setting-structured-loggin:
+
+``structured-logging``
+---------------------
+.. versionadded:: 4.6.0
+
+- Boolean
+- Default: yes
+
+Prefer structured logging when both an old style and a structured log messages is available.
+
 .. _setting-tcp-fast-open:
 
 ``tcp-fast-open``
index 6e90ee3b0c2637e087f0cf91abf805b1e2b74d48..2870849fdeb3f14f2742e2d3622ceb2381cd09e0 100644 (file)
@@ -11,14 +11,18 @@ Offensive language
 ^^^^^^^^^^^^^^^^^^
 Using the settings mentioned in :ref:`upgrade-offensive` now generates a warning. Please start using the new names.
 
-Deprecated and changed settings
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
--  The :ref:`setting-api-key` and :ref:`setting-webserver-password` settings now accept a hashed and salted version (if the support is available in the openssl library used).
+New settings
+^^^^^^^^^^^^
 - The :ref:`setting-dot-to-auth-names` setting to list nameservers that should be contacted over DoT has been introduced.
 - The :ref:`setting-dot-to-port-853` setting to specify that nameservers or forwarders using port 853 should be contacted over DoT has been introduced.
 - The :ref:`setting-ignore-unknown-settings` setting has been introduced to make it easier to switch between recursor versions supporting different settings.
 - The :ref:`setting-webserver-hash-plaintext-credentials` has been introduced to avoid keeping cleartext sensitive information in memory.
 - The :ref:`setting-tcp-out-max-idle-ms`, :ref:`setting-tcp-out-max-idle-per-auth`, :ref:`setting-tcp-out-max-queries` and :ref:`setting-tcp-out-max-idle-per-thread` settings have been introduced to control the new TCP/DoT outgoing connections pooling. This mechanism keeps connections to authoritative servers or forwarders open for later re-use.
+- The :ref:`setting-structured-logging` setting has been introduced to prefer structured logging when both an old style and a structured log messages is available.
+
+Deprecated and changed settings
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-  The :ref:`setting-api-key` and :ref:`setting-webserver-password` settings now accept a hashed and salted version (if the support is available in the openssl library used).
 
 
 4.5.1 to 4.5.2
index 7fe236342199275c2908b27060eac02a51b86e2d..6196ba3b8f7a8aa572a0668c00c3bd2b15ea492c 100644 (file)
@@ -177,4 +177,4 @@ Logger::~Logger()
 };
 
 std::shared_ptr<Logging::Logger> g_slog{nullptr};
-bool g_slogOldStyle = false;
+bool g_slogStructured = true;
index 7d28856d4acf352da191c12758f5a81fb059761d..fb03332d3ad3466687597df4e5bcac7959685add 100644 (file)
@@ -117,21 +117,21 @@ private:
 
 extern std::shared_ptr<Logging::Logger> g_slog;
 
-// The list of subsystem names that use structured logging
-extern bool g_slogOldStyle;
+// Prefer structured logging?
+extern bool g_slogStructured;
 
-// A helper macro to switch between odl-style logging and new-style (structured logging)
+// A helper macro to switch between old-style logging and new-style (structured logging)
 // A typical use:
 //
 // SLOG(g_log<<Logger::Warning<<"Unable to parse configuration file '"<<configname<<"'"<<endl,
 //      startupLog->error("No such file", "Unable to parse configuration file", "config_file", Logging::Loggable(configname));
 //
-#define SLOG(oldStyle, slogCall)  \
-  do {                            \
-    if (!g_slogOldStyle) {        \
-      slogCall;                   \
-    }                             \
-    else {                        \
-      oldStyle;                   \
-    }                             \
+#define SLOG(oldStyle, slogCall) \
+  do {                           \
+    if (g_slogStructured) {      \
+      slogCall;                  \
+    }                            \
+    else {                       \
+      oldStyle;                  \
+    }                            \
   } while (0);