From: Remi Gacogne Date: Tue, 30 Dec 2025 14:22:45 +0000 (+0100) Subject: dnsdist: Fix consistency issues in structured logging keys X-Git-Tag: rec-5.4.0-beta1~33^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a45c5031fed6e3833fe9473db19a423258dbaa8;p=thirdparty%2Fpdns.git dnsdist: Fix consistency issues in structured logging keys Signed-off-by: Remi Gacogne --- diff --git a/pdns/dnsdistdist/dnsdist-actions-factory.cc b/pdns/dnsdistdist/dnsdist-actions-factory.cc index 111673ac00..d2753a5e7b 100644 --- a/pdns/dnsdistdist/dnsdist-actions-factory.cc +++ b/pdns/dnsdistdist/dnsdist-actions-factory.cc @@ -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))); } } diff --git a/pdns/dnsdistdist/dnsdist-configuration-yaml.cc b/pdns/dnsdistdist/dnsdist-configuration-yaml.cc index f065f0e782..5ca65eed1f 100644 --- a/pdns/dnsdistdist/dnsdist-configuration-yaml.cc +++ b/pdns/dnsdistdist/dnsdist-configuration-yaml.cc @@ -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 diff --git a/pdns/dnsdistdist/dnsdist-dnsquestion.cc b/pdns/dnsdistdist/dnsdist-dnsquestion.cc index 7c5763d39e..cf7e7c656f 100644 --- a/pdns/dnsdistdist/dnsdist-dnsquestion.cc +++ b/pdns/dnsdistdist/dnsdist-dnsquestion.cc @@ -82,7 +82,7 @@ std::shared_ptr DNSResponse::getThisLogger(std::shared_ptrwithValues("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; } diff --git a/pdns/dnsdistdist/dnsdist-dynblocks.cc b/pdns/dnsdistdist/dnsdist-dynblocks.cc index 11d9079554..6c0122dbea 100644 --- a/pdns/dnsdistdist/dnsdist-dynblocks.cc +++ b/pdns/dnsdistdist/dnsdist-dynblocks.cc @@ -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; diff --git a/pdns/dnsdistdist/dnsdist-kvs.cc b/pdns/dnsdistdist/dnsdist-kvs.cc index ca54675c78..465595dbe2 100644 --- a/pdns/dnsdistdist/dnsdist-kvs.cc +++ b/pdns/dnsdistdist/dnsdist-kvs.cc @@ -83,7 +83,7 @@ std::vector KeyValueLookupKeySuffix::getKeys(const DNSName& qname) #ifdef HAVE_LMDB std::shared_ptr 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 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; } diff --git a/pdns/dnsdistdist/dnsdist-lbpolicies.cc b/pdns/dnsdistdist/dnsdist-lbpolicies.cc index a387381878..35975f9ecb 100644 --- a/pdns/dnsdistdist/dnsdist-lbpolicies.cc +++ b/pdns/dnsdistdist/dnsdist-lbpolicies.cc @@ -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) { diff --git a/pdns/dnsdistdist/dnsdist-lua.cc b/pdns/dnsdistdist/dnsdist-lua.cc index 1ee86e19f2..03d613628e 100644 --- a/pdns/dnsdistdist/dnsdist-lua.cc +++ b/pdns/dnsdistdist/dnsdist-lua.cc @@ -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(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> 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); diff --git a/pdns/dnsdistdist/dnsdist-tcp.cc b/pdns/dnsdistdist/dnsdist-tcp.cc index 5c12f2f813..0c0148fb13 100644 --- a/pdns/dnsdistdist/dnsdist-tcp.cc +++ b/pdns/dnsdistdist/dnsdist-tcp.cc @@ -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) { diff --git a/pdns/dnsdistdist/dnsdist-web.cc b/pdns/dnsdistdist/dnsdist-web.cc index 5d8e100fdc..c242be5ab6 100644 --- a/pdns/dnsdistdist/dnsdist-web.cc +++ b/pdns/dnsdistdist/dnsdist-web.cc @@ -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; } diff --git a/pdns/dnsdistdist/dnsdist.cc b/pdns/dnsdistdist/dnsdist.cc index 7d9840c4e4..c74fd102ee 100644 --- a/pdns/dnsdistdist/dnsdist.cc +++ b/pdns/dnsdistdist/dnsdist.cc @@ -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(); } diff --git a/pdns/dnsdistdist/doq-common.cc b/pdns/dnsdistdist/doq-common.cc index 16bdfe359d..9df896a0b7 100644 --- a/pdns/dnsdistdist/doq-common.cc +++ b/pdns/dnsdistdist/doq-common.cc @@ -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))); } }