From: Otto Date: Tue, 12 Oct 2021 10:19:55 +0000 (+0200) Subject: Add setting to switch to non-structed logging X-Git-Tag: dnsdist-1.7.0-alpha2~22^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb8d885f94d3ba9730e061bb4d585616edc8a5e9;p=thirdparty%2Fpdns.git Add setting to switch to non-structed logging --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index e8781acebe..7a70587280 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -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"); diff --git a/pdns/recursordist/docs/settings.rst b/pdns/recursordist/docs/settings.rst index eab06acac5..959388acdd 100644 --- a/pdns/recursordist/docs/settings.rst +++ b/pdns/recursordist/docs/settings.rst @@ -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`` diff --git a/pdns/recursordist/docs/upgrade.rst b/pdns/recursordist/docs/upgrade.rst index 6e90ee3b0c..2870849fde 100644 --- a/pdns/recursordist/docs/upgrade.rst +++ b/pdns/recursordist/docs/upgrade.rst @@ -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 diff --git a/pdns/recursordist/logging.cc b/pdns/recursordist/logging.cc index 7fe2363421..6196ba3b8f 100644 --- a/pdns/recursordist/logging.cc +++ b/pdns/recursordist/logging.cc @@ -177,4 +177,4 @@ Logger::~Logger() }; std::shared_ptr g_slog{nullptr}; -bool g_slogOldStyle = false; +bool g_slogStructured = true; diff --git a/pdns/recursordist/logging.hh b/pdns/recursordist/logging.hh index 7d28856d4a..fb03332d3a 100644 --- a/pdns/recursordist/logging.hh +++ b/pdns/recursordist/logging.hh @@ -117,21 +117,21 @@ private: extern std::shared_ptr 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<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);