]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix consistency issues in structured logging keys
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 30 Dec 2025 14:22:45 +0000 (15:22 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 19 Jan 2026 10:01:28 +0000 (11:01 +0100)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
pdns/dnsdistdist/dnsdist-actions-factory.cc
pdns/dnsdistdist/dnsdist-configuration-yaml.cc
pdns/dnsdistdist/dnsdist-dnsquestion.cc
pdns/dnsdistdist/dnsdist-dynblocks.cc
pdns/dnsdistdist/dnsdist-kvs.cc
pdns/dnsdistdist/dnsdist-lbpolicies.cc
pdns/dnsdistdist/dnsdist-lua.cc
pdns/dnsdistdist/dnsdist-tcp.cc
pdns/dnsdistdist/dnsdist-web.cc
pdns/dnsdistdist/dnsdist.cc
pdns/dnsdistdist/doq-common.cc

index 111673ac00858ec4a311a9b06c007544fc9392bf..d2753a5e7b9692cc8b94f015b7fe2c54270b5308 100644 (file)
@@ -1177,7 +1177,7 @@ public:
     if (!reopenLogFile()) {
       int savederrno = errno;
       SLOG(warnlog("Unable to open file '%s' for logging: %s", d_fname, stringerror(savederrno)),
-           dnsdist::logging::getTopLogger()->error(Logr::Warning, savederrno, "Unable to open file for logging", "filename", Logging::Loggable(d_fname)));
+           dnsdist::logging::getTopLogger()->error(Logr::Warning, savederrno, "Unable to open file for logging", "path", Logging::Loggable(d_fname)));
     }
   }
 
@@ -1271,7 +1271,7 @@ public:
     if (!reopenLogFile()) {
       int savederrno = errno;
       SLOG(warnlog("Unable to open file '%s' for logging: %s", d_fname, stringerror(savederrno)),
-           dnsdist::logging::getTopLogger()->error(Logr::Warning, savederrno, "Unable to open file for logging", "filename", Logging::Loggable(d_fname)));
+           dnsdist::logging::getTopLogger()->error(Logr::Warning, savederrno, "Unable to open file for logging", "path", Logging::Loggable(d_fname)));
     }
   }
 
index f065f0e7820a640fc3454cae6d80fe68fa704eed..5ca65eed1fa6c30d4227f591ee34c08845e92790 100644 (file)
@@ -976,7 +976,7 @@ static void handleLoggingConfiguration(const Context& context, const dnsdist::ru
     }
     catch (const std::exception& e) {
       SLOG(errlog("Error while opening the verbose logging destination file %s: %s", dest, e.what()),
-           context.logger->error(Logr::Error, e.what(), "Error while opening the verbose logging destination file", "filename", Logging::Loggable(dest)));
+           context.logger->error(Logr::Error, e.what(), "Error while opening the verbose logging destination file", "path", Logging::Loggable(dest)));
     }
   }
 
@@ -1133,7 +1133,7 @@ bool loadConfigurationFromFile(const std::string& fileName, [[maybe_unused]] boo
   // Rust code would be quite cumbersome so for now let's settle for this
   s_inConfigCheckMode.store(configCheck);
   s_inClientMode.store(isClient);
-  auto logger = dnsdist::logging::getTopLogger()->withName("yaml-configuration")->withValues("dnsdist.configuration.file", Logging::Loggable(fileName), "dnsdist.configuration.client_mode", Logging::Loggable(isClient), "dnsdist.configuration.check", Logging::Loggable(configCheck));
+  auto logger = dnsdist::logging::getTopLogger()->withName("yaml-configuration")->withValues("path", Logging::Loggable(fileName), "client_mode", Logging::Loggable(isClient), "configuration_check", Logging::Loggable(configCheck));
   Context context{
     .logger = logger,
   };
@@ -1281,7 +1281,7 @@ bool loadConfigurationFromFile(const std::string& fileName, [[maybe_unused]] boo
         auto [poolIt, inserted] = config.d_pools.emplace(std::string(pool.name), ServerPool());
         if (inserted) {
           VERBOSESLOG(infolog("Creating pool %s", pool.name),
-                      context.logger->info(Logr::Info, "Creating pool", "pool.name", Logging::Loggable(pool.name)));
+                      context.logger->info(Logr::Info, "Creating pool", "pool", Logging::Loggable(pool.name)));
         }
 
         if (!pool.packet_cache.empty()) {
@@ -1308,15 +1308,15 @@ bool loadConfigurationFromFile(const std::string& fileName, [[maybe_unused]] boo
   }
   catch (const ::rust::Error& exp) {
     SLOG(errlog("Error while parsing YAML file %s: %s", fileName, exp.what()),
-         logger->error(Logr::Error, exp.what(), "Error while parsing YAML file", "dnsdist.configuration.file", Logging::Loggable(fileName)));
+         logger->error(Logr::Error, exp.what(), "Error while parsing YAML file", "path", Logging::Loggable(fileName)));
   }
   catch (const PDNSException& exp) {
     SLOG(errlog("Error while processing YAML configuration from file %s: %s", fileName, exp.reason),
-         logger->error(Logr::Error, exp.reason, "Error while processing YAML file", "dnsdist.configuration.file", Logging::Loggable(fileName)));
+         logger->error(Logr::Error, exp.reason, "Error while processing YAML file", "path", Logging::Loggable(fileName)));
   }
   catch (const std::exception& exp) {
     SLOG(errlog("Error while processing YAML configuration from file %s: %s", fileName, exp.what()),
-         logger->error(Logr::Error, exp.what(), "Error while processing YAML file", "dnsdist.configuration.file", Logging::Loggable(fileName)));
+         logger->error(Logr::Error, exp.what(), "Error while processing YAML file", "path", Logging::Loggable(fileName)));
   }
   return false;
 #else
index 7c5763d39e46d727d2d3abd889f5ab8acaaa0b56..cf7e7c656fc904d8beff2eee3e1faf5fd04d0922 100644 (file)
@@ -82,7 +82,7 @@ std::shared_ptr<const Logr::Logger> DNSResponse::getThisLogger(std::shared_ptr<c
     logger = logger->withValues("backend.protocol", Logging::Loggable(d_downstream->getProtocol()), "backend.name", Logging::Loggable(d_downstream->getName()), "backend.address", Logging::Loggable(d_downstream->d_config.remote));
   }
   const double udiff = ids.queryRealTime.udiff();
-  logger = logger->withValues("dns.response.latency-us", Logging::Loggable(udiff), "dns.response.size", Logging::Loggable(data.size()));
+  logger = logger->withValues("dns.response.latency_us", Logging::Loggable(udiff), "dns.response.size", Logging::Loggable(data.size()));
   return logger;
 }
 
index 11d9079554a6d1df48ad3a5f23ee5389becd1091..6c0122dbea9eff3768d1b575bfc116213a34ecdc 100644 (file)
@@ -269,7 +269,7 @@ bool addOrRefreshBlock(ClientAddressDynamicRules& blocks, const timespec& now, c
 
     if (!beQuiet) {
       SLOG(warnlog("Inserting %s%sdynamic block for %s for %d seconds: %s", dblock.warning ? "(warning) " : "", bpf ? "eBPF " : "", requestor.toString(), dblock.until.tv_sec - now.tv_sec, dblock.reason),
-           dnsdist::logging::getTopLogger()->withName("dynamic-rules")->info(Logr::Warning, "Inserting dynamic rule", "dynamic_rule.warning_rule", Logging::Loggable(dblock.warning), "client.address", Logging::Loggable(requestor), "dynamic_rule.use_bpf", Logging::Loggable(bpf), "dyanmic_rule.reason", Logging::Loggable(dblock.reason), "dynamic_rule.duration", Logging::Loggable(dblock.until.tv_sec - now.tv_sec)));
+           dnsdist::logging::getTopLogger()->withName("dynamic-rules")->info(Logr::Warning, "Inserting dynamic rule", "dynamic_rule.warning_rule", Logging::Loggable(dblock.warning), "client.address", Logging::Loggable(requestor), "dynamic_rule.use_bpf", Logging::Loggable(bpf), "dynamic_rule.reason", Logging::Loggable(dblock.reason), "dynamic_rule.duration", Logging::Loggable(dblock.until.tv_sec - now.tv_sec)));
     }
   }
 
@@ -311,7 +311,7 @@ bool addOrRefreshBlockSMT(SuffixDynamicRules& blocks, const timespec& now, DynBl
 
   if (!beQuiet && (got == nullptr || expired)) {
     SLOG(warnlog("Inserting dynamic block for %s for %d seconds: %s", dblock.domain, dblock.until.tv_sec - now.tv_sec, dblock.reason),
-         dnsdist::logging::getTopLogger()->withName("dynamic-rules")->info(Logr::Warning, "Inserting dynamic rule", "dynamic_rule.warning_rule", Logging::Loggable(false), "dns.query.name", Logging::Loggable(dblock.domain), "dynamic_rule.use_bpf", Logging::Loggable(false), "dyanmic_rule.reason", Logging::Loggable(dblock.reason), "dynamic_rule.duration", Logging::Loggable(dblock.until.tv_sec - now.tv_sec)));
+         dnsdist::logging::getTopLogger()->withName("dynamic-rules")->info(Logr::Warning, "Inserting dynamic rule", "dynamic_rule.warning_rule", Logging::Loggable(false), "dns.query.name", Logging::Loggable(dblock.domain), "dynamic_rule.use_bpf", Logging::Loggable(false), "dynamic_rule.reason", Logging::Loggable(dblock.reason), "dynamic_rule.duration", Logging::Loggable(dblock.until.tv_sec - now.tv_sec)));
   }
 
   auto domain = dblock.domain;
index ca54675c78e8e0674ed87e74ae700b6c7a3f59a5..465595dbe2e711de0470e909d2f41faeccb3e675 100644 (file)
@@ -83,7 +83,7 @@ std::vector<std::string> KeyValueLookupKeySuffix::getKeys(const DNSName& qname)
 #ifdef HAVE_LMDB
 std::shared_ptr<const Logr::Logger> LMDBKVStore::getLogger() const
 {
-  return dnsdist::logging::getTopLogger()->withName("lmdb-key-value-store")->withValues("lmdb.filename", Logging::Loggable(d_fname), "lmdb.database", Logging::Loggable(d_dbName));
+  return dnsdist::logging::getTopLogger()->withName("lmdb-key-value-store")->withValues("path", Logging::Loggable(d_fname), "database", Logging::Loggable(d_dbName));
 }
 
 bool LMDBKVStore::getValue(const std::string& key, std::string& value)
@@ -102,7 +102,7 @@ bool LMDBKVStore::getValue(const std::string& key, std::string& value)
   }
   catch (const std::exception& e) {
     VERBOSESLOG(infolog("Error while looking up key '%s' from LMDB file '%s', database '%s': %s", key, d_fname, d_dbName, e.what()),
-                getLogger()->error(Logr::Info, e.what(), "Error while looking up key", "lmdb.key", Logging::Loggable(key)));
+                getLogger()->error(Logr::Info, e.what(), "Error while looking up key", "key", Logging::Loggable(key)));
   }
   return false;
 }
@@ -122,7 +122,7 @@ bool LMDBKVStore::keyExists(const std::string& key)
   }
   catch (const std::exception& e) {
     VERBOSESLOG(infolog("Error while looking up key '%s' from LMDB file '%s', database '%s': %s", key, d_fname, d_dbName, e.what()),
-                getLogger()->error(Logr::Info, e.what(), "Error while looking up key", "lmdb.key", Logging::Loggable(key)));
+                getLogger()->error(Logr::Info, e.what(), "Error while looking up key", "key", Logging::Loggable(key)));
   }
   return false;
 }
@@ -171,7 +171,7 @@ bool LMDBKVStore::getRangeValue(const std::string& key, std::string& value)
   }
   catch (const std::exception& e) {
     VERBOSESLOG(infolog("Error while looking up a range from LMDB file '%s', database '%s': %s", d_fname, d_dbName, e.what()),
-                getLogger()->error(Logr::Info, e.what(), "Error while looking up a range", "lmdb.key", Logging::Loggable(key)));
+                getLogger()->error(Logr::Info, e.what(), "Error while looking up a range", "key", Logging::Loggable(key)));
   }
   return false;
 }
@@ -181,7 +181,7 @@ bool LMDBKVStore::getRangeValue(const std::string& key, std::string& value)
 #ifdef HAVE_CDB
 std::shared_ptr<const Logr::Logger> CDBKVStore::getLogger() const
 {
-  return dnsdist::logging::getTopLogger()->withName("cdb-key-value-store")->withValues("cdb.filename", Logging::Loggable(d_fname));
+  return dnsdist::logging::getTopLogger()->withName("cdb-key-value-store")->withValues("path", Logging::Loggable(d_fname));
 }
 
 CDBKVStore::CDBKVStore(const std::string& fname, time_t refreshDelay): d_fname(fname), d_refreshDelay(refreshDelay)
@@ -269,7 +269,7 @@ bool CDBKVStore::getValue(const std::string& key, std::string& value)
   }
   catch (const std::exception& e) {
     VERBOSESLOG(infolog("Error while looking up key '%s' from CDB file '%s': %s", key, d_fname, e.what()),
-                getLogger()->error(Logr::Info, e.what(), "Error while looking up a key", "cdb.key", Logging::Loggable(key)));
+                getLogger()->error(Logr::Info, e.what(), "Error while looking up a key", "key", Logging::Loggable(key)));
   }
   return false;
 }
@@ -294,7 +294,7 @@ bool CDBKVStore::keyExists(const std::string& key)
   }
   catch (const std::exception& e) {
     VERBOSESLOG(infolog("Error while looking up key '%s' from CDB file '%s': %s", key, d_fname, e.what()),
-                getLogger()->error(Logr::Info, e.what(), "Error while looking up a key", "cdb.key", Logging::Loggable(key)));
+                getLogger()->error(Logr::Info, e.what(), "Error while looking up a key", "key", Logging::Loggable(key)));
   }
   return false;
 }
index a387381878d9aab1663c0e4d88fad52dedbd811d..35975f9ecb58f8e7cc82555633d2fbaa1a3e0c95 100644 (file)
@@ -327,7 +327,7 @@ const ServerPool& createPoolIfNotExists(const string& poolName)
 
   if (!poolName.empty()) {
     VERBOSESLOG(infolog("Creating pool %s", poolName),
-               dnsdist::logging::getTopLogger()->info(Logr::Info, "Creating a new pool of backends", "name", Logging::Loggable(poolName)));
+               dnsdist::logging::getTopLogger()->info(Logr::Info, "Creating a new pool of backends", "pool", Logging::Loggable(poolName)));
   }
 
   dnsdist::configuration::updateRuntimeConfiguration([&poolName](dnsdist::configuration::RuntimeConfiguration& config) {
index 1ee86e19f2e84e9bc3175d6af40782b20ada573f..03d613628ea643ca9b12a64dd6a53da7a2b0cdbc 100644 (file)
@@ -1742,7 +1742,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
 
     if (created) {
       VERBOSESLOG(infolog("Creating pool %s", poolName),
-                  getLogger("getPool")->info(Logr::Info, "Creating a new pool", "pool.name", Logging::Loggable(poolName)));
+                  getLogger("getPool")->info(Logr::Info, "Creating a new pool", "pool", Logging::Loggable(poolName)));
     }
 
     return std::make_shared<dnsdist::lua::LuaServerPoolObject>(poolName);
@@ -1758,7 +1758,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
     }
     catch (const std::exception& e) {
       SLOG(errlog("Error while opening the verbose logging destination file %s: %s", dest, e.what()),
-           getLogger("setVerboseLogDestination")->error(Logr::Error, e.what(), "Error while opening the verbose logging destination file", "filename", Logging::Loggable(dest)));
+           getLogger("setVerboseLogDestination")->error(Logr::Error, e.what(), "Error while opening the verbose logging destination file", "path", Logging::Loggable(dest)));
     }
   });
   luaCtx.writeFunction("setStructuredLogging", [](bool enable, std::optional<LuaAssociativeTable<std::string>> options) {
@@ -1925,7 +1925,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
 
     if (s_included) {
       SLOG(errlog("includeDirectory() cannot be used recursively!"),
-           getLogger("includeDirectory")->info(Logr::Error, "includeDirectory cannot be used recursively", "directory", Logging::Loggable(dirname)));
+           getLogger("includeDirectory")->info(Logr::Error, "includeDirectory cannot be used recursively", "path", Logging::Loggable(dirname)));
       g_outputBuffer = "includeDirectory() cannot be used recursively!\n";
       return;
     }
@@ -1933,14 +1933,14 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
     struct stat dirStat{};
     if (stat(dirname.c_str(), &dirStat) != 0) {
       SLOG(errlog("The included directory %s does not exist!", dirname),
-           getLogger("includeDirectory")->info(Logr::Error, "The included directory does not exist", "directory", Logging::Loggable(dirname)));
+           getLogger("includeDirectory")->info(Logr::Error, "The included directory does not exist", "path", Logging::Loggable(dirname)));
       g_outputBuffer = "The included directory " + dirname + " does not exist!";
       return;
     }
 
     if (!S_ISDIR(dirStat.st_mode)) {
       SLOG(errlog("The included directory %s is not a directory!", dirname),
-           getLogger("includeDirectory")->info(Logr::Error, "The included directory is not a directory", "directory", Logging::Loggable(dirname)));
+           getLogger("includeDirectory")->info(Logr::Error, "The included directory is not a directory", "path", Logging::Loggable(dirname)));
       g_outputBuffer = "The included directory " + dirname + " is not a directory!";
       return;
     }
@@ -1963,7 +1963,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
 
     if (directoryError) {
       SLOG(errlog("Error opening included directory: %s!", *directoryError),
-           getLogger("includeDirectory")->error(Logr::Error, *directoryError, "Error opening included directory", "directory", Logging::Loggable(dirname)));
+           getLogger("includeDirectory")->error(Logr::Error, *directoryError, "Error opening included directory", "path", Logging::Loggable(dirname)));
       g_outputBuffer = "Error opening included directory: " + *directoryError + "!";
       return;
     }
@@ -1976,11 +1976,11 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
       std::ifstream ifs(file);
       if (!ifs) {
         SLOG(warnlog("Unable to read configuration from '%s'", file),
-             getLogger("includeDirectory")->info(Logr::Warning, "Unable to read configuration from included directory file", "directory", Logging::Loggable(dirname), "filename", Logging::Loggable(file)));
+             getLogger("includeDirectory")->info(Logr::Warning, "Unable to read configuration from included directory file", "path", Logging::Loggable(dirname), "filename", Logging::Loggable(file)));
       }
       else {
         VERBOSESLOG(infolog("Read configuration from '%s'", file),
-                    getLogger("includeDirectory")->info(Logr::Info, "Read configuration from file", "directory", Logging::Loggable(dirname), "filename", Logging::Loggable(file)));
+                    getLogger("includeDirectory")->info(Logr::Info, "Read configuration from file", "path", Logging::Loggable(dirname), "filename", Logging::Loggable(file)));
       }
 
       try {
@@ -3349,11 +3349,11 @@ void loadLuaConfigurationFile(LuaContext& luaCtx, const std::string& config, boo
       throw std::runtime_error("Unable to read configuration file from " + config);
     }
     SLOG(warnlog("Unable to read configuration from '%s'", config),
-         dnsdist::logging::getTopLogger()->withName("lua-configuration")->info(Logr::Error, "Unable to read configuration from file", "dnsdist.configuration.file", Logging::Loggable(config)));
+         dnsdist::logging::getTopLogger()->withName("lua-configuration")->info(Logr::Error, "Unable to read configuration from file", "path", Logging::Loggable(config)));
   }
   else {
     VERBOSESLOG(infolog("Read configuration from '%s'", config),
-                dnsdist::logging::getTopLogger()->withName("lua-configuration")->info(Logr::Info, "Read configuration from file", "dnsdist.configuration.file", Logging::Loggable(config)));
+                dnsdist::logging::getTopLogger()->withName("lua-configuration")->info(Logr::Info, "Read configuration from file", "path", Logging::Loggable(config)));
   }
 
   luaCtx.executeCode(ifs);
index 5c12f2f813c4eb230c01d7fd6482280fbd573a9b..0c0148fb13f76e54b6d28ffc3b837a9f41654582 100644 (file)
@@ -257,7 +257,7 @@ void IncomingTCPConnectionState::handleResponseSent(TCPResponse& currentResponse
     const auto& ids = currentResponse.d_idstate;
     auto udiff = ids.queryRealTime.udiff();
     VERBOSESLOG(infolog("Got answer from %s, relayed to %s (%s, %d bytes), took %d us", backend->d_config.remote.toStringWithPort(), ids.origRemote.toStringWithPort(), getProtocol().toString(), sentBytes, udiff),
-                ids.getLogger(getLogger())->info(Logr::Info, "Relayed response to client", "backend.name", Logging::Loggable(backend->getName()), "backend.address", Logging::Loggable(backend->d_config.remote), "dns.response.size", Logging::Loggable(sentBytes), "dns.response.latency-us", Logging::Loggable(udiff)));
+                ids.getLogger(getLogger())->info(Logr::Info, "Relayed response to client", "backend.name", Logging::Loggable(backend->getName()), "backend.address", Logging::Loggable(backend->d_config.remote), "dns.response.size", Logging::Loggable(sentBytes), "dns.response.latency_us", Logging::Loggable(udiff)));
 
     auto backendProtocol = backend->getProtocol();
     if (backendProtocol == dnsdist::Protocol::DoUDP && !currentResponse.d_idstate.forwardedOverUDP) {
index 5d8e100fdcdb946ef338a25bf8fc3ee98a0c200a..c242be5ab67fd313cc6f36cf6fbdb990ae82b21d 100644 (file)
@@ -239,13 +239,13 @@ static bool apiWriteConfigFile(const string& filebasename, const string& content
   const auto& runtimeConfig = dnsdist::configuration::getCurrentRuntimeConfiguration();
   if (!runtimeConfig.d_apiReadWrite) {
     SLOG(warnlog("Not writing content to %s since the API is read-only", filebasename),
-         logger.info(Logr::Warning, "Not writing content to file since the API is read-only", "filename", Logging::Loggable(filebasename)));
+         logger.info(Logr::Warning, "Not writing content to file since the API is read-only", "path", Logging::Loggable(filebasename)));
     return false;
   }
 
   if (runtimeConfig.d_apiConfigDirectory.empty()) {
     VERBOSESLOG(infolog("Not writing content to %s since the API configuration directory is not set", filebasename),
-                logger.info(Logr::Info, "Not writing content to file since the API configuration directory is not set", "filename", Logging::Loggable(filebasename)));
+                logger.info(Logr::Info, "Not writing content to file since the API configuration directory is not set", "path", Logging::Loggable(filebasename)));
 
     return false;
   }
@@ -255,7 +255,7 @@ static bool apiWriteConfigFile(const string& filebasename, const string& content
   if (!ofconf) {
     int saved = errno;
     SLOG(errlog("Could not open configuration fragment file '%s' for writing: %s", filename, stringerror(saved)),
-         logger.error(Logr::Error, saved, "Could not open configuration fragment file for writing", "filename", Logging::Loggable(filebasename)));
+         logger.error(Logr::Error, saved, "Could not open configuration fragment file for writing", "path", Logging::Loggable(filebasename)));
 
     return false;
   }
index 7d9840c4e4045f2a286fe7b4eeaf450ce3e3170a..c74fd102eeeaba5912fd5fab2551c14d94700509 100644 (file)
@@ -140,7 +140,7 @@ static void sendfromto(int sock, const PacketBuffer& buffer, const ComboAddress&
     if (ret == -1) {
       int error = errno;
       VERBOSESLOG(infolog("Error sending UDP response to %s: %s", dest.toStringWithPort(), stringerror(error)),
-                  dnsdist::logging::getTopLogger()->withName("sendfromto")->error(error, "Error sending UDP response", "destination.address", Logging::Loggable(dest)));
+                  dnsdist::logging::getTopLogger()->withName("sendfromto")->error(error, "Error sending UDP response", "client.address", Logging::Loggable(dest)));
     }
     return;
   }
@@ -150,7 +150,7 @@ static void sendfromto(int sock, const PacketBuffer& buffer, const ComboAddress&
   }
   catch (const std::exception& exp) {
     VERBOSESLOG(infolog("Error sending UDP response from %s to %s: %s", from.toStringWithPort(), dest.toStringWithPort(), exp.what()),
-                dnsdist::logging::getTopLogger()->withName("sendfromto")->error(exp.what(), "Error sending UDP response", "source.address", Logging::Loggable(from), "destination.address", Logging::Loggable(dest)));
+                dnsdist::logging::getTopLogger()->withName("sendfromto")->error(exp.what(), "Error sending UDP response", "source.address", Logging::Loggable(from), "client.address", Logging::Loggable(dest)));
   }
 }
 
@@ -1301,7 +1301,7 @@ static bool isUDPQueryAcceptable(ClientState& clientState, const struct msghdr*
   if ((msgh->msg_flags & MSG_TRUNC) != 0) {
     /* message was too large for our buffer */
     VERBOSESLOG(infolog("Dropping message too large for our buffer"),
-                dnsdist::logging::getTopLogger()->info("Dropping query from client that is too large for our buffer", "source.address", Logging::Loggable(dest), "destination.address", Logging::Loggable(clientState.local)));
+                dnsdist::logging::getTopLogger()->info("Dropping query from client that is too large for our buffer", "client.address", Logging::Loggable(remote), "destination.address", Logging::Loggable(dest), "frontend.address", Logging::Loggable(clientState.local)));
     ++clientState.nonCompliantQueries;
     ++dnsdist::metrics::g_stats.nonCompliantQueries;
     return false;
@@ -3575,13 +3575,13 @@ static bool loadConfigurationFromFile(const std::string& configurationFile, bool
 
     if (auto tentativeLuaConfFile = lookForTentativeConfigurationFileWithExtension(configurationFile, "lua")) {
       VERBOSESLOG(infolog("Loading configuration from auto-discovered Lua file %s", *tentativeLuaConfFile),
-                  logger->info(Logr::Info, "Loading configuration from auto-discovered Lua file", "dnsdist.configuration.file", Logging::Loggable(*tentativeLuaConfFile)));
+                  logger->info(Logr::Info, "Loading configuration from auto-discovered Lua file", "path", Logging::Loggable(*tentativeLuaConfFile)));
 
       dnsdist::configuration::lua::loadLuaConfigurationFile(*(g_lua.lock()), *tentativeLuaConfFile, configCheck);
     }
 
     VERBOSESLOG(infolog("Loading configuration from YAML file %s", configurationFile),
-                logger->info(Logr::Info, "Loading configuration from YAML file", "dnsdist.configuration.file", Logging::Loggable(configurationFile)));
+                logger->info(Logr::Info, "Loading configuration from YAML file", "path", Logging::Loggable(configurationFile)));
 
     if (!dnsdist::configuration::yaml::loadConfigurationFromFile(configurationFile, isClient, configCheck)) {
       return false;
@@ -3595,18 +3595,18 @@ static bool loadConfigurationFromFile(const std::string& configurationFile, bool
   dnsdist::lua::setupLua(*(g_lua.lock()), isClient, configCheck);
   if (boost::ends_with(configurationFile, ".lua")) {
     VERBOSESLOG(infolog("Loading configuration from Lua file %s", configurationFile),
-                logger->info(Logr::Info, "Loading configuration from Lua file", "dnsdist.configuration.file", Logging::Loggable(configurationFile)));
+                logger->info(Logr::Info, "Loading configuration from Lua file", "path", Logging::Loggable(configurationFile)));
 
     dnsdist::configuration::lua::loadLuaConfigurationFile(*(g_lua.lock()), configurationFile, configCheck);
     if (auto tentativeYamlConfFile = lookForTentativeConfigurationFileWithExtension(configurationFile, "yml")) {
       VERBOSESLOG(infolog("Loading configuration from auto-discovered YAML file %s", *tentativeYamlConfFile),
-                  logger->info(Logr::Info, "Loading configuration from auto-discovered YAML file", "dnsdist.configuration.file", Logging::Loggable(*tentativeYamlConfFile)));
+                  logger->info(Logr::Info, "Loading configuration from auto-discovered YAML file", "path", Logging::Loggable(*tentativeYamlConfFile)));
       return dnsdist::configuration::yaml::loadConfigurationFromFile(*tentativeYamlConfFile, isClient, configCheck);
     }
   }
   else {
     VERBOSESLOG(infolog("Loading configuration from Lua file %s", configurationFile),
-                logger->info(Logr::Info, "Loading configuration from Lua file", "dnsdist.configuration.file", Logging::Loggable(configurationFile)));
+                logger->info(Logr::Info, "Loading configuration from Lua file", "path", Logging::Loggable(configurationFile)));
 
     dnsdist::configuration::lua::loadLuaConfigurationFile(*(g_lua.lock()), configurationFile, configCheck);
   }
@@ -3662,8 +3662,9 @@ int main(int argc, char** argv)
       config.d_structuredLogging = cmdLine.useStructuredLogging;
     });
 
-    if (cmdLine.useStructuredLogging) {
+    if (cmdLine.useStructuredLogging && !cmdLine.structuredLoggingBackend.empty()) {
       dnsdist::logging::setup(cmdLine.structuredLoggingBackend);
+      setupLogger = dnsdist::logging::getTopLogger()->withName("setup");
     }
 
     dnsdist::configuration::updateRuntimeConfiguration([](dnsdist::configuration::RuntimeConfiguration& config) {
@@ -3716,7 +3717,7 @@ int main(int argc, char** argv)
       }
       // No exception was thrown
       SLOG(infolog("Configuration '%s' OK!", cmdLine.config),
-           setupLogger->info(Logr::Info, "Configuration OK", "dnsdist.configuration.file", Logging::Loggable(cmdLine.config)));
+           setupLogger->info(Logr::Info, "Configuration OK", "path", Logging::Loggable(cmdLine.config)));
       doExitNicely();
     }
 
index 16bdfe359d4fdea6dcd61db7a534c54157eabcb7..9df896a0b7ff10d13b38532feaa27e692a56e151 100644 (file)
@@ -149,7 +149,7 @@ static void sendFromTo(Socket& sock, const ComboAddress& peer, const ComboAddres
     if (ret < 0) {
       auto error = errno;
       VERBOSESLOG(infolog("Error while sending QUIC datagram of size %d to %s: %s", buffer.size(), peer.toStringWithPort(), stringerror(error)),
-                  dnsdist::logging::getTopLogger()->error(Logr::Info, error, "Error while sending QUIC datagram", "datagram_size", Logging::Loggable(buffer.size()), "destination.address", Logging::Loggable(peer)));
+                  dnsdist::logging::getTopLogger()->error(Logr::Info, error, "Error while sending QUIC datagram", "datagram_size", Logging::Loggable(buffer.size()), "client.address", Logging::Loggable(peer)));
     }
     return;
   }
@@ -159,7 +159,7 @@ static void sendFromTo(Socket& sock, const ComboAddress& peer, const ComboAddres
   }
   catch (const std::exception& exp) {
     VERBOSESLOG(infolog("Error while sending QUIC datagram of size %d from %s to %s: %s", buffer.size(), local.toStringWithPort(), peer.toStringWithPort(), exp.what()),
-                dnsdist::logging::getTopLogger()->error(Logr::Info, exp.what(), "Error while sending QUIC datagram", "datagram_size", Logging::Loggable(buffer.size()), "source.address", Logging::Loggable(local), "destination.address", Logging::Loggable(peer)));
+                dnsdist::logging::getTopLogger()->error(Logr::Info, exp.what(), "Error while sending QUIC datagram", "datagram_size", Logging::Loggable(buffer.size()), "source.address", Logging::Loggable(local), "client.address", Logging::Loggable(peer)));
   }
 }