/* Check if the current soft memlock limit is at least the limit */
if (old_limit.rlim_cur < new_limit_size) {
SLOG(infolog("The current limit of locked memory (soft: %d, hard: %d) is too low for eBPF, trying to raise it to %d", old_limit.rlim_cur, old_limit.rlim_max, new_limit_size),
- dnsdist::logging::getTopLogger()->info("The current limit of locked memory is too low for eBPF, trying to raise it", "soft", Logging::Loggable(old_limit.rlim_cur), "hard", Logging::Loggable(old_limit.rlim_max), "target", Logging::Loggable(new_limit_size)));
+ dnsdist::logging::getTopLogger("bpf")->info("The current limit of locked memory is too low for eBPF, trying to raise it", "soft", Logging::Loggable(old_limit.rlim_cur), "hard", Logging::Loggable(old_limit.rlim_max), "target", Logging::Loggable(new_limit_size)));
struct rlimit new_limit{};
new_limit.rlim_cur = new_limit_size;
if (setrlimit(RLIMIT_MEMLOCK, &new_limit) != 0) {
SLOG(warnlog("Unable to raise the maximum amount of locked memory for eBPF from %d to %d, consider raising RLIMIT_MEMLOCK or setting LimitMEMLOCK in the systemd unit: %d", old_limit.rlim_cur, new_limit.rlim_cur, stringerror()),
- dnsdist::logging::getTopLogger()->info(Logr::Warning, "Unable to raise the maximum amount of locked memory for eBPF, consider raising RLIMIT_MEMLOCK or setting LimitMEMLOCK in the systemd unit", "current", Logging::Loggable(old_limit.rlim_cur), "target", Logging::Loggable(new_limit_size)));
+ dnsdist::logging::getTopLogger("bpf")->info(Logr::Warning, "Unable to raise the maximum amount of locked memory for eBPF, consider raising RLIMIT_MEMLOCK or setting LimitMEMLOCK in the systemd unit", "current", Logging::Loggable(old_limit.rlim_cur), "target", Logging::Loggable(new_limit_size)));
}
}
#ifdef DNSCRYPT_STRICT_PADDING_LENGTH
if (tcp && ((packet.size() - sizeof(DNSCryptQueryHeader)) % DNSCRYPT_PADDED_BLOCK_SIZE) != 0) {
VERBOSESLOG(infolog("Dropping encrypted query with invalid size of %d (should be a multiple of %d)", (packet.size() - sizeof(DNSCryptQueryHeader)), DNSCRYPT_PADDED_BLOCK_SIZE),
- dnsdist::logging::getTopLogger()->info("Dropping DNSCrypt-encrypted query with invalid size (should be a multiple of " DNSCRYPT_PADDED_BLOCK_SIZE, "dns.question.size", Logging::Loggable(packet.size() - sizeof(DNSCryptQueryHeader))));
+ dnsdist::logging::getTopLogger("dnscrypt")->info("Dropping DNSCrypt-encrypted query with invalid size (should be a multiple of " DNSCRYPT_PADDED_BLOCK_SIZE, "dns.question.size", Logging::Loggable(packet.size() - sizeof(DNSCryptQueryHeader))));
return;
}
#endif
int res = computeSharedKey();
if (res != 0) {
VERBOSESLOG(infolog("Dropping encrypted query we can't compute the shared key for"),
- dnsdist::logging::getTopLogger()->info("Dropping DNSCrypt-encrypted query we can't compute the shared key for"));
+ dnsdist::logging::getTopLogger("dnscrypt")->info("Dropping DNSCrypt-encrypted query we can't compute the shared key for"));
return;
}
if (res != 0) {
VERBOSESLOG(infolog("Dropping encrypted query we can't decrypt"),
- dnsdist::logging::getTopLogger()->error(Logr::Info, res, "Dropping DNSCrypt-encrypted query we couldn't decrypt"));
+ dnsdist::logging::getTopLogger("dnscrypt")->error(Logr::Info, res, "Dropping DNSCrypt-encrypted query we couldn't decrypt"));
return;
}
uint16_t pos = decryptedQueryLen;
if (pos >= packet.size()) {
VERBOSESLOG(infolog("Dropping encrypted query we can't decrypt (invalid position)"),
- dnsdist::logging::getTopLogger()->info("Dropping DNSCrypt-encrypted we couldn't decrypt because of an invalid position", "position", Logging::Loggable(pos), "dns.question.size", Logging::Loggable(packet.size())));
+ dnsdist::logging::getTopLogger("dnscrypt")->info("Dropping DNSCrypt-encrypted we couldn't decrypt because of an invalid position", "position", Logging::Loggable(pos), "dns.question.size", Logging::Loggable(packet.size())));
return;
}
if (pos == 0 || packet.at(pos - 1) != 0x80) {
VERBOSESLOG(infolog("Dropping encrypted query with invalid padding value"),
- dnsdist::logging::getTopLogger()->info("Dropping DNSCrypt-encrypted query with invalid padding value"));
+ dnsdist::logging::getTopLogger("dnscrypt")->info("Dropping DNSCrypt-encrypted query with invalid padding value"));
return;
}
if (tcp && paddingLen > DNSCRYPT_MAX_TCP_PADDING_SIZE) {
VERBOSESLOG(infolog("Dropping encrypted query with too long padding size"),
- dnsdist::logging::getTopLogger()->info("Dropping DNSCrypt-encrypted query withtoo long padding size"));
+ dnsdist::logging::getTopLogger("dnscrypt")->info("Dropping DNSCrypt-encrypted query withtoo long padding size"));
return;
}
}
catch (const std::exception& e) {
SLOG(errlog(e.what()),
- dnsdist::logging::getTopLogger()->error(e.what(), "Error while generating DNSCrypt certificate"));
+ dnsdist::logging::getTopLogger("dnscrypt")->error(e.what(), "Error while generating DNSCrypt certificate"));
}
sodium_memzero(providerPrivateKey.data(), providerPrivateKey.size());
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", "path", Logging::Loggable(d_fname)));
+ dnsdist::logging::getTopLogger("LogAction::reload")->error(Logr::Warning, savederrno, "Unable to open file for logging", "path", Logging::Loggable(d_fname)));
}
}
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", "path", Logging::Loggable(d_fname)));
+ dnsdist::logging::getTopLogger("LogResponseAction::reload")->error(Logr::Warning, savederrno, "Unable to open file for logging", "path", Logging::Loggable(d_fname)));
}
}
break;
case RemoteLoggerInterface::Result::PipeFull: {
VERBOSESLOG(infolog("%s: %s", remoteLogger.name(), RemoteLoggerInterface::toErrorString(ret)),
- dnsdist::logging::getTopLogger()->error(Logr::Info, RemoteLoggerInterface::toErrorString(ret), "Remote logger pipe full event", "remote_logger_name", Logging::Loggable(remoteLogger.name())));
+ dnsdist::logging::getTopLogger("remote-logger")->error(Logr::Info, RemoteLoggerInterface::toErrorString(ret), "Remote logger pipe full event", "remote_logger_name", Logging::Loggable(remoteLogger.name())));
break;
}
case RemoteLoggerInterface::Result::TooLarge: {
SLOG(warnlog("%s: %s", remoteLogger.name(), RemoteLoggerInterface::toErrorString(ret)),
- dnsdist::logging::getTopLogger()->error(Logr::Warning, RemoteLoggerInterface::toErrorString(ret), "Remote logger too large event", "remote_logger_name", Logging::Loggable(remoteLogger.name())));
+ dnsdist::logging::getTopLogger("remote-logger")->error(Logr::Warning, RemoteLoggerInterface::toErrorString(ret), "Remote logger too large event", "remote_logger_name", Logging::Loggable(remoteLogger.name())));
break;
}
case RemoteLoggerInterface::Result::OtherError:
SLOG(warnlog("%s: %s", remoteLogger.name(), RemoteLoggerInterface::toErrorString(ret)),
- dnsdist::logging::getTopLogger()->error(Logr::Warning, RemoteLoggerInterface::toErrorString(ret), "Remote logger error event", "remote_logger_name", Logging::Loggable(remoteLogger.name())));
+ dnsdist::logging::getTopLogger("remote-logger")->error(Logr::Warning, RemoteLoggerInterface::toErrorString(ret), "Remote logger error event", "remote_logger_name", Logging::Loggable(remoteLogger.name())));
}
}
expiredEvents.pop_front();
if (!data->d_failOpen) {
VERBOSESLOG(infolog("Asynchronous query %d has expired at %d.%d, notifying the sender", queryID, now.tv_sec, now.tv_usec),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Asynchronous query has expired, notifying the sender", "dns.question.id", Logging::Loggable(queryID)));
+ dnsdist::logging::getTopLogger("async-thread")->info(Logr::Info, "Asynchronous query has expired, notifying the sender", "dns.question.id", Logging::Loggable(queryID)));
auto sender = query->getTCPQuerySender();
if (sender) {
TCPResponse tresponse(std::move(query->query));
}
else {
VERBOSESLOG(infolog("Asynchronous query %d has expired at %d.%d, resuming", queryID, now.tv_sec, now.tv_usec),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Asynchronous query has expired, resuming", "dns.question.id", Logging::Loggable(queryID)));
+ dnsdist::logging::getTopLogger("async-thread")->info(Logr::Info, "Asynchronous query has expired, resuming", "dns.question.id", Logging::Loggable(queryID)));
resumeQuery(std::move(query));
}
}
timeval now{};
gettimeofday(&now, nullptr);
VERBOSESLOG(infolog("Asynchronous object %d not found at %d.%d", queryID, now.tv_sec, now.tv_usec),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Asynchronous object not found", "dnsdist.async.id", Logging::Loggable(asyncID), "dns.question.id", Logging::Loggable(queryID)));
+ dnsdist::logging::getTopLogger("async-holder")->info(Logr::Info, "Asynchronous object not found", "dnsdist.async.id", Logging::Loggable(asyncID), "dns.question.id", Logging::Loggable(queryID)));
return nullptr;
}
}
catch (const std::exception& e) {
VERBOSESLOG(infolog("Got exception while resuming cross-protocol response: %s", e.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Info, e.what(), "Got exception while resuming cross-protocol response"));
+ dnsdist::logging::getTopLogger("async-holder")->error(Logr::Info, e.what(), "Got exception while resuming cross-protocol response"));
return false;
}
}
if (query && !resumeQuery(std::move(query))) {
VERBOSESLOG(infolog("Unable to resume asynchronous query event"),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Unable to resume asynchronous query event"));
+ dnsdist::logging::getTopLogger("async-holder")->info(Logr::Info, "Unable to resume asynchronous query event"));
}
}
}
}
catch (const std::exception& e) {
VERBOSESLOG(infolog("Got exception while resuming cross-protocol self-answered query: %s", e.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Info, e.what(), "Got exception while resuming cross-protocol self-answered query"));
+ dnsdist::logging::getTopLogger("async-holder")->error(Logr::Info, e.what(), "Got exception while resuming cross-protocol self-answered query"));
return false;
}
}
if (result == ProcessQueryResult::Asynchronous) {
/* nope */
SLOG(errlog("processQueryAfterRules returned 'asynchronous' while trying to resume an already asynchronous query"),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "processQueryAfterRules returned 'asynchronous' while trying to resume an already asynchronous query"));
+ dnsdist::logging::getTopLogger("async-holder")->info(Logr::Info, "processQueryAfterRules returned 'asynchronous' while trying to resume an already asynchronous query"));
return false;
}
{
const auto hashPerturbation = dnsdist::configuration::getImmutableConfiguration().d_hashPerturbation;
VERBOSESLOG(infolog("Computing hashes for id=%s and weight=%d, hash_perturbation=%d", *d_config.id, d_config.d_weight, hashPerturbation),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Computing hashes for backend", "backend.id", Logging::Loggable(*d_config.id), "backend.weight", Logging::Loggable(d_config.d_weight), "backend.hash_perturbation", Logging::Loggable(hashPerturbation)));
+ dnsdist::logging::getTopLogger("backend")->info(Logr::Info, "Computing hashes for backend", "backend.id", Logging::Loggable(*d_config.id), "backend.weight", Logging::Loggable(d_config.d_weight), "backend.hash_perturbation", Logging::Loggable(hashPerturbation)));
auto weight = d_config.d_weight;
auto idStr = boost::str(boost::format("%s") % *d_config.id);
}
SLOG(warnlog("Dismissing source %s because '%s' is not a valid interface name", source, config.sourceItfName),
- dnsdist::logging::getTopLogger()->info(Logr::Warning, "Dismissing source because the interface name is not valid", "backend.name", Logging::Loggable(config.name), "backend.address", Logging::Loggable(config.remote), "source.address", Logging::Loggable(source), "source.interface", Logging::Loggable(config.sourceItfName)));
+ dnsdist::logging::getTopLogger("backend")->info(Logr::Warning, "Dismissing source because the interface name is not valid", "backend.name", Logging::Loggable(config.name), "backend.address", Logging::Loggable(config.remote), "source.address", Logging::Loggable(source), "source.interface", Logging::Loggable(config.sourceItfName)));
return false;
}
[[nodiscard]] std::shared_ptr<const Logr::Logger> DownstreamState::getLogger() const
{
- return dnsdist::logging::getTopLogger()->withName("backend")->withValues("backend.name", Logging::Loggable(getName()), "backend.address", Logging::Loggable(d_config.remote), "backend.protocol", Logging::Loggable(getProtocol()));
+ return dnsdist::logging::getTopLogger("backend")->withValues("backend.name", Logging::Loggable(getName()), "backend.address", Logging::Loggable(d_config.remote), "backend.protocol", Logging::Loggable(getProtocol()));
}
size_t ServerPool::countServers(bool upOnly) const
{
setThreadName("dnsdist/carbon");
const auto ourName = endpoint.getOurName();
- auto logger = dnsdist::logging::getTopLogger()->withName("carbon-exporter")->withValues("server.address", Logging::Loggable(endpoint.server), "dnsdist.carbon.our_name", Logging::Loggable(ourName));
+ auto logger = dnsdist::logging::getTopLogger("carbon-exporter")->withValues("server.address", Logging::Loggable(endpoint.server), "dnsdist.carbon.our_name", Logging::Loggable(ourName));
const auto intervalUSec = endpoint.interval * 1000 * 1000;
/* maximum interval between two attempts is 10 minutes */
auto checkConnectionAllowed = [now, from, maxConnsPerClient, threshold, tcpRate, tlsNewRate, tlsResumedRate, interval, isTLS, &immutable](const ClientEntry& entry) {
if (entry.d_bannedUntil != 0 && entry.d_bannedUntil >= now) {
VERBOSESLOG(infolog("Refusing TCP connection from %s: banned", from.toStringWithPort()),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Refusing TCP connection", "reason", Logging::Loggable("banned"), "client.address", Logging::Loggable(from)));
+ dnsdist::logging::getTopLogger("concurrent-tcp-connections-manager")->info(Logr::Info, "Refusing TCP connection", "reason", Logging::Loggable("banned"), "client.address", Logging::Loggable(from)));
return NewConnectionResult::Denied;
}
if (maxConnsPerClient > 0 && entry.d_concurrentConnections >= maxConnsPerClient) {
VERBOSESLOG(infolog("Refusing TCP connection from %s: too many connections", from.toStringWithPort()),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Refusing TCP connection", "reason", Logging::Loggable("too many connections"), "client.address", Logging::Loggable(from)));
+ dnsdist::logging::getTopLogger("concurrent-tcp-connections-manager")->info(Logr::Info, "Refusing TCP connection", "reason", Logging::Loggable("too many connections"), "client.address", Logging::Loggable(from)));
return NewConnectionResult::Denied;
}
if (!checkTCPConnectionsRate(entry.d_activity, now, tcpRate, tlsNewRate, tlsResumedRate, interval, isTLS)) {
entry.d_bannedUntil = now + immutable.d_tcpBanDurationForExceedingTCPTLSRate;
VERBOSESLOG(infolog("Banning TCP connections from %s for %d seconds: too many new TCP/TLS connections per second", from.toStringWithPort(), immutable.d_tcpBanDurationForExceedingTCPTLSRate),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Banning TCP connections from this client", "reason", Logging::Loggable("too many new TCP/TLS connections per second"), "client.address", Logging::Loggable(from), "duration-seconds", Logging::Loggable(immutable.d_tcpBanDurationForExceedingTCPTLSRate)));
+ dnsdist::logging::getTopLogger("concurrent-tcp-connections-manager")->info(Logr::Info, "Banning TCP connections from this client", "reason", Logging::Loggable("too many new TCP/TLS connections per second"), "client.address", Logging::Loggable(from), "duration-seconds", Logging::Loggable(immutable.d_tcpBanDurationForExceedingTCPTLSRate)));
return NewConnectionResult::Denied;
}
return NewConnectionResult::Allowed;
}
VERBOSESLOG(infolog("Restricting TCP connection from %s: nearly reaching the maximum number of concurrent TCP connections", from.toStringWithPort()),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Restricting TCP connections from this client", "reason", Logging::Loggable("nearly reaching the maximum number of concurrent TCP connections"), "client.address", Logging::Loggable(from)));
+ dnsdist::logging::getTopLogger("concurrent-tcp-connections-manager")->info(Logr::Info, "Restricting TCP connections from this client", "reason", Logging::Loggable("nearly reaching the maximum number of concurrent TCP connections"), "client.address", Logging::Loggable(from)));
return NewConnectionResult::Restricted;
};
});
}
VERBOSESLOG(infolog("Banned TCP client %s for %d seconds", from.toStringWithPort(), seconds),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Banned TCP connections from this client", "client.address", Logging::Loggable(from), "duration-seconds", Logging::Loggable(seconds)));
+ dnsdist::logging::getTopLogger("concurrent-tcp-connections-manager")->info(Logr::Info, "Banned TCP connections from this client", "client.address", Logging::Loggable(from), "duration-seconds", Logging::Loggable(seconds)));
}
static void editEntryIfPresent(const ComboAddress& from, const std::function<void(const ClientEntry& entry)>& callback)
// 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("path", Logging::Loggable(fileName), "client_mode", Logging::Loggable(isClient), "configuration_check", Logging::Loggable(configCheck));
+ auto logger = dnsdist::logging::getTopLogger("yaml-configuration")->withValues("path", Logging::Loggable(fileName), "client_mode", Logging::Loggable(isClient), "configuration_check", Logging::Loggable(configCheck));
Context context{
.logger = logger,
};
}
#else
SLOG(errlog("Client mode requested but libedit support is not available"),
- dnsdist::logging::getTopLogger()->info(Logr::Error, "Client mode requested but libedit support is not available"));
+ dnsdist::logging::getTopLogger("console-client")->info(Logr::Error, "Client mode requested but libedit support is not available"));
#endif /* HAVE_LIBEDIT */
}
{
setThreadName("dnsdist/control");
const ComboAddress local = dnsdist::configuration::getCurrentRuntimeConfiguration().d_consoleServerAddress;
- auto logger = dnsdist::logging::getTopLogger()->withName("console-server")->withValues("network.local.address", Logging::Loggable(local));
+ auto logger = dnsdist::logging::getTopLogger("console-server")->withValues("network.local.address", Logging::Loggable(local));
try {
s_connManager.setMaxConcurrentConnections(dnsdist::configuration::getImmutableConfiguration().d_consoleMaxConcurrentConnections);
try {
ConsoleConnection conn(client, std::move(socket));
- auto connLogger = dnsdist::logging::getTopLogger()->withName("console-connection")->withValues("client.address", Logging::Loggable(client));
+ auto connLogger = dnsdist::logging::getTopLogger("console-connection")->withValues("client.address", Logging::Loggable(client));
if (runtimeConfig.d_logConsoleConnections) {
SLOG(warnlog("Got control connection from %s", client.toStringWithPort()),
connLogger->info(Logr::Info, "Control connection opened"));
void ServiceDiscovery::worker()
{
setThreadName("dnsdist/discove");
- auto logger = dnsdist::logging::getTopLogger()->withName("service-discovery");
+ auto logger = dnsdist::logging::getTopLogger("service-discovery");
while (true) {
dnsdist::configuration::refreshLocalRuntimeConfiguration();
if (!query.isValid()) {
VERBOSESLOG(infolog("Dropping DNSCrypt invalid query"),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Dropping DNSCrypt invalid query"));
+ dnsdist::logging::getTopLogger("dnscrypt")->info(Logr::Info, "Dropping DNSCrypt invalid query"));
return false;
}
}
catch (const std::exception& e) {
VERBOSESLOG(infolog("Unable to insert eBPF dynamic block for %s, falling back to regular dynamic block: %s", requestor.toString(), e.what()),
- dnsdist::logging::getTopLogger()->withName("dynamic-rules")->error(Logr::Info, e.what(), "Unable to insert eBPF dynamic block, falling back to regular dynamic block", "client.address", Logging::Loggable(requestor)));
+ dnsdist::logging::getTopLogger("dynamic-rules")->error(Logr::Info, e.what(), "Unable to insert eBPF dynamic block, falling back to regular dynamic block", "client.address", Logging::Loggable(requestor)));
}
}
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), "dynamic_rule.reason", Logging::Loggable(dblock.reason), "dynamic_rule.duration", Logging::Loggable(dblock.until.tv_sec - now.tv_sec)));
+ dnsdist::logging::getTopLogger("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)));
}
}
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), "dynamic_rule.reason", Logging::Loggable(dblock.reason), "dynamic_rule.duration", Logging::Loggable(dblock.until.tv_sec - now.tv_sec)));
+ dnsdist::logging::getTopLogger("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;
}
catch (const std::exception& exp) {
SLOG(warnlog("Error calling the Lua hook after a dynamic block insertion: %s", exp.what()),
- dnsdist::logging::getTopLogger()->withName("dynamic-rules")->error(Logr::Warning, exp.what(), "Error calling the Lua hook after a dynamic rule insertion"));
+ dnsdist::logging::getTopLogger("dynamic-rules")->error(Logr::Warning, exp.what(), "Error calling the Lua hook after a dynamic rule insertion"));
}
}
}
}
catch (const std::exception& exp) {
SLOG(warnlog("Error calling the Lua hook after a dynamic block insertion: %s", exp.what()),
- dnsdist::logging::getTopLogger()->withName("dynamic-rules")->error(Logr::Warning, exp.what(), "Error calling the Lua hook after a suffix-based dynamic rule insertion"));
+ dnsdist::logging::getTopLogger("dynamic-rules")->error(Logr::Warning, exp.what(), "Error calling the Lua hook after a suffix-based dynamic rule insertion"));
}
}
}
}
catch (const std::exception& e) {
VERBOSESLOG(infolog("Error while getting block count before removing eBPF dynamic block for %s: %s", entry.first.toString(), e.what()),
- dnsdist::logging::getTopLogger()->withName("dynamic-rules")->error(Logr::Info, e.what(), "Error while getting block count before removing eBPF dynamic block", "dynamic_rule.key", Logging::Loggable(entry.first)));
+ dnsdist::logging::getTopLogger("dynamic-rules")->error(Logr::Info, e.what(), "Error while getting block count before removing eBPF dynamic block", "dynamic_rule.key", Logging::Loggable(entry.first)));
}
try {
}
catch (const std::exception& e) {
VERBOSESLOG(infolog("Error while removing eBPF dynamic block for %s: %s", entry.first.toString(), e.what()),
- dnsdist::logging::getTopLogger()->withName("dynamic-rules")->error(Logr::Info, e.what(), "Error while removing eBPF dynamic block", "dynamic_rule.key", Logging::Loggable(entry.first)));
+ dnsdist::logging::getTopLogger("dynamic-rules")->error(Logr::Info, e.what(), "Error while removing eBPF dynamic block", "dynamic_rule.key", Logging::Loggable(entry.first)));
}
}
}
}
catch (const std::exception& e) {
SLOG(warnlog("Error in the dynamic block maintenance thread: %s", e.what()),
- dnsdist::logging::getTopLogger()->withName("dynamic-rules")->error(Logr::Warning, e.what(), "Error in the dynamic block maintenance thread"));
+ dnsdist::logging::getTopLogger("dynamic-rules")->error(Logr::Warning, e.what(), "Error in the dynamic block maintenance thread"));
}
catch (...) {
VERBOSESLOG(infolog("Unhandled error in the dynamic block maintenance thread"),
- dnsdist::logging::getTopLogger()->withName("dynamic-rules")->info(Logr::Info, "Unhandled error in the dynamic block maintenance thread"));
+ dnsdist::logging::getTopLogger("dynamic-rules")->info(Logr::Info, "Unhandled error in the dynamic block maintenance thread"));
}
}
}
static std::shared_ptr<Logr::Logger> getLoggerFromData(const std::shared_ptr<const HealthCheckData>& data)
{
const auto& downstream = data->d_ds;
- return dnsdist::logging::getTopLogger()->withName("backend-health-check")->withValues("health_check.proto", Logging::Loggable(downstream->doHealthcheckOverTCP() ? (data->d_tcpHandler->isTLS() ? "DoT" : "tcp") : "udp"), "backend.name", Logging::Loggable(downstream->getName()), "backend.address", Logging::Loggable(downstream->d_config.remote), "dns.query.id", Logging::Loggable(data->d_queryID), "dns.query.name", Logging::Loggable(data->d_checkName), "dns.query.type", Logging::Loggable(data->d_checkType), "dns.query.class", Logging::Loggable(data->d_checkClass));
+ return dnsdist::logging::getTopLogger("backend-health-check")->withValues("health_check.proto", Logging::Loggable(downstream->doHealthcheckOverTCP() ? (data->d_tcpHandler->isTLS() ? "DoT" : "tcp") : "udp"), "backend.name", Logging::Loggable(downstream->getName()), "backend.address", Logging::Loggable(downstream->d_config.remote), "dns.query.id", Logging::Loggable(data->d_queryID), "dns.query.name", Logging::Loggable(data->d_checkName), "dns.query.type", Logging::Loggable(data->d_checkType), "dns.query.class", Logging::Loggable(data->d_checkClass));
}
static bool handleResponse(std::shared_ptr<HealthCheckData>& data)
const auto verboseHealthChecks = dnsdist::configuration::getCurrentRuntimeConfiguration().d_verboseHealthChecks;
std::shared_ptr<Logr::Logger> logger;
if (verboseHealthChecks) {
- logger = dnsdist::logging::getTopLogger()->withName("backend-health-check")->withValues("backend.name", Logging::Loggable(downstream->getName()), "backend.address", Logging::Loggable(downstream->d_config.remote));
+ logger = dnsdist::logging::getTopLogger("backend-health-check")->withValues("backend.name", Logging::Loggable(downstream->getName()), "backend.address", Logging::Loggable(downstream->d_config.remote));
}
try {
void handleQueuedHealthChecks(FDMultiplexer& mplexer, bool initial)
{
const auto verboseHealthChecks = dnsdist::configuration::getCurrentRuntimeConfiguration().d_verboseHealthChecks;
- std::shared_ptr<Logr::Logger> logger;
+ std::shared_ptr<const Logr::Logger> logger;
if (verboseHealthChecks) {
- logger = dnsdist::logging::getTopLogger()->withName("backend-health-check");
+ logger = dnsdist::logging::getTopLogger("backend-health-check");
}
while (mplexer.getWatchedFDCount(false) > 0 || mplexer.getWatchedFDCount(true) > 0) {
std::shared_ptr<const Logr::Logger> InternalQueryState::getLogger(std::shared_ptr<const Logr::Logger> parent) const
{
if (!parent) {
- parent = dnsdist::logging::getTopLogger();
+ parent = dnsdist::logging::getTopLogger("query-processing");
}
auto logger = parent->withValues("dns.question.name", Logging::Loggable(this->qname), "dns.question.type", Logging::Loggable(this->qtype), "dns.question.class", Logging::Loggable(this->qclass), "source.address", Logging::Loggable(this->origRemote), "destination.address", Logging::Loggable(this->origDest), "proto", Logging::Loggable(this->protocol), "dns.question.id", Logging::Loggable(ntohs(this->origID)), "dns.question.flags", Logging::Loggable(this->origFlags));
return logger;
#ifdef HAVE_LMDB
std::shared_ptr<const Logr::Logger> LMDBKVStore::getLogger() const
{
- return dnsdist::logging::getTopLogger()->withName("lmdb-key-value-store")->withValues("path", Logging::Loggable(d_fname), "database", Logging::Loggable(d_dbName));
+ return dnsdist::logging::getTopLogger("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)
#ifdef HAVE_CDB
std::shared_ptr<const Logr::Logger> CDBKVStore::getLogger() const
{
- return dnsdist::logging::getTopLogger()->withName("cdb-key-value-store")->withValues("path", Logging::Loggable(d_fname));
+ return dnsdist::logging::getTopLogger("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)
if (!poolName.empty()) {
VERBOSESLOG(infolog("Creating pool %s", poolName),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Creating a new pool of backends", "pool", Logging::Loggable(poolName)));
+ dnsdist::logging::getTopLogger("pool")->info(Logr::Info, "Creating a new pool of backends", "pool", Logging::Loggable(poolName)));
}
dnsdist::configuration::updateRuntimeConfiguration([&poolName](dnsdist::configuration::RuntimeConfiguration& config) {
{
if (!poolName.empty()) {
VERBOSESLOG(infolog("Setting pool %s server selection policy to %s", poolName, policy->getName()),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Setting pool server selection policy", "pool", Logging::Loggable(poolName), "policy", Logging::Loggable(policy->getName())));
+ dnsdist::logging::getTopLogger("pool")->info(Logr::Info, "Setting pool server selection policy", "pool", Logging::Loggable(poolName), "policy", Logging::Loggable(policy->getName())));
} else {
VERBOSESLOG(infolog("Setting default pool server selection policy to %s", policy->getName()),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Setting pool server selection policy", "pool", Logging::Loggable(poolName), "policy", Logging::Loggable(policy->getName())));
+ dnsdist::logging::getTopLogger("pool")->info(Logr::Info, "Setting pool server selection policy", "pool", Logging::Loggable(poolName), "policy", Logging::Loggable(policy->getName())));
}
{
if (!poolName.empty()) {
VERBOSESLOG(infolog("Adding server to pool %s", poolName),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Adding server to pool", "pool", Logging::Loggable(poolName)));
+ dnsdist::logging::getTopLogger("pool")->info(Logr::Info, "Adding server to pool", "pool", Logging::Loggable(poolName)));
} else {
VERBOSESLOG(infolog("Adding server to default pool"),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Adding server to pool", "pool", Logging::Loggable(poolName)));
+ dnsdist::logging::getTopLogger("pool")->info(Logr::Info, "Adding server to pool", "pool", Logging::Loggable(poolName)));
}
dnsdist::configuration::updateRuntimeConfiguration([&poolName, &server](dnsdist::configuration::RuntimeConfiguration& config) {
{
if (!poolName.empty()) {
VERBOSESLOG(infolog("Removing server from pool %s", poolName),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Removing server from pool", "pool", Logging::Loggable(poolName)));
+ dnsdist::logging::getTopLogger("pool")->info(Logr::Info, "Removing server from pool", "pool", Logging::Loggable(poolName)));
}
else {
VERBOSESLOG(infolog("Removing server from default pool"),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Removing server from pool", "pool", Logging::Loggable(poolName)));
+ dnsdist::logging::getTopLogger("pool")->info(Logr::Info, "Removing server from pool", "pool", Logging::Loggable(poolName)));
}
dnsdist::configuration::updateRuntimeConfiguration([&poolName, &server](dnsdist::configuration::RuntimeConfiguration& config) {
}
}
-std::shared_ptr<const Logr::Logger> getTopLogger()
+std::shared_ptr<const Logr::Logger> getTopLogger(const std::string_view& subsystem)
{
auto topLogger = std::atomic_load_explicit(&s_topLogger, std::memory_order_acquire);
if (!topLogger) {
throw std::runtime_error("Trying to access the top-level logger before logging has been setup");
}
- return topLogger;
+ return topLogger->withName(std::string(subsystem));
}
bool doVerboseLogging()
#include <memory>
#include <string>
+#include <string_view>
#include "logging.hh"
namespace dnsdist::logging
{
void setup(const std::string& backend);
-std::shared_ptr<const Logr::Logger> getTopLogger();
+std::shared_ptr<const Logr::Logger> getTopLogger(const std::string_view& subsystem);
bool doVerboseLogging();
bool doStructuredLogging();
}
}
catch (const std::exception& e) {
SLOG(errlog("Error generating a DNSCrypt certificate: %s", e.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Error, e.what(), "Error generating a DNSCrypt certificate"));
+ dnsdist::logging::getTopLogger("lua")->error(Logr::Error, e.what(), "Error generating a DNSCrypt certificate"));
g_outputBuffer = "Error generating a DNSCrypt certificate: " + string(e.what()) + "\n";
return false;
}
}
catch (const std::exception& e) {
SLOG(errlog("Error generating a DNSCrypt certificate: %s", e.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Error, e.what(), "Error generating a DNSCrypt certificate"));
+ dnsdist::logging::getTopLogger("lua")->error(Logr::Error, e.what(), "Error generating a DNSCrypt certificate"));
g_outputBuffer = "Error generating a DNSCrypt certificate: " + string(e.what()) + "\n";
}
});
}
catch (const std::exception& e) {
SLOG(errlog("Error generating a DNSCrypt provider key: %s", e.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Error, e.what(), "Error generating a DNSCrypt provider key"));
+ dnsdist::logging::getTopLogger("lua")->error(Logr::Error, e.what(), "Error generating a DNSCrypt provider key"));
g_outputBuffer = "Error generating a DNSCrypt provider key: " + string(e.what()) + "\n";
}
}
catch (const std::exception& e) {
SLOG(errlog("Error getting a DNSCrypt provider fingerprint: %s", e.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Error, e.what(), "Error getting a DNSCrypt provider fingerprint"));
+ dnsdist::logging::getTopLogger("lua")->error(Logr::Error, e.what(), "Error getting a DNSCrypt provider fingerprint"));
g_outputBuffer = "Error getting a DNSCrypt provider fingerprint: " + string(e.what()) + "\n";
}
});
}
catch (const std::exception& e) {
SLOG(warnlog("Error connecting to network endpoint: %s", e.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Error, e.what(), "Error connecting to network endpoint"));
+ dnsdist::logging::getTopLogger("newNetworkEndpoint")->error(Logr::Error, e.what(), "Error connecting to network endpoint"));
}
return std::shared_ptr<dnsdist::NetworkEndpoint>(nullptr);
});
if (maxEntries < settings.d_shardCount) {
SLOG(warnlog("The number of entries (%d) in the packet cache is smaller than the number of shards (%d), decreasing the number of shards to %d", maxEntries, settings.d_shardCount, maxEntries),
- dnsdist::logging::getTopLogger()->withName("configuration")->info(Logr::Warning, "The number of entries in the packet cache is smaller than the number of shards, decreasing the number of shards to the number of entries", "number_of_entries", Logging::Loggable(maxEntries), "number_of_shards", Logging::Loggable(settings.d_shardCount)));
+ dnsdist::logging::getTopLogger("configuration")->info(Logr::Warning, "The number of entries in the packet cache is smaller than the number of shards, decreasing the number of shards to the number of entries", "number_of_entries", Logging::Loggable(maxEntries), "number_of_shards", Logging::Loggable(settings.d_shardCount)));
g_outputBuffer += "The number of entries (" + std::to_string(maxEntries) + " in the packet cache is smaller than the number of shards (" + std::to_string(settings.d_shardCount) + "), decreasing the number of shards to " + std::to_string(maxEntries);
settings.d_shardCount = maxEntries;
}
{
luaCtx.writeFunction("vinfolog", [](const string& arg) {
VERBOSESLOG(infolog("%s", arg),
- dnsdist::logging::getTopLogger()->withName("lua-message")->info(Logr::Info, arg));
+ dnsdist::logging::getTopLogger("lua-message")->info(Logr::Info, arg));
});
luaCtx.writeFunction("infolog", [](const string& arg) {
SLOG(infolog("%s", arg),
- dnsdist::logging::getTopLogger()->withName("lua-message")->info(Logr::Info, arg));
+ dnsdist::logging::getTopLogger("lua-message")->info(Logr::Info, arg));
});
luaCtx.writeFunction("errlog", [](const string& arg) {
SLOG(errlog("%s", arg),
- dnsdist::logging::getTopLogger()->withName("lua-message")->info(Logr::Error, arg));
+ dnsdist::logging::getTopLogger("lua-message")->info(Logr::Error, arg));
});
luaCtx.writeFunction("warnlog", [](const string& arg) {
SLOG(warnlog("%s", arg),
- dnsdist::logging::getTopLogger()->withName("lua-message")->info(Logr::Warning, arg));
+ dnsdist::logging::getTopLogger("lua-message")->info(Logr::Warning, arg));
});
luaCtx.writeFunction("show", [](const string& arg) {
g_outputBuffer += arg;
}
catch (const std::exception& exp) {
VERBOSESLOG(infolog("Error during execution of getAddressInfo callback: %s", exp.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Error, exp.what(), "Error during execution of getAddressInfo callback"));
+ dnsdist::logging::getTopLogger("getAddressInfo")->error(Logr::Error, exp.what(), "Error during execution of getAddressInfo callback"));
}
// this _needs_ to be done while we are holding the lock,
// otherwise the destructor will corrupt the stack
{"setPayloadSizeOnSelfGeneratedAnswers", {[](dnsdist::configuration::RuntimeConfiguration& config, uint64_t newValue) {
if (newValue < 512) {
SLOG(warnlog("setPayloadSizeOnSelfGeneratedAnswers() is set too low, using 512 instead!"),
- dnsdist::logging::getTopLogger()->withName("configuration")->info(Logr::Warning, "Value passed to setPayloadSizeOnSelfGeneratedAnswers() is set too low, using 512 instead", "value", Logging::Loggable(newValue)));
+ dnsdist::logging::getTopLogger("configuration")->info(Logr::Warning, "Value passed to setPayloadSizeOnSelfGeneratedAnswers() is set too low, using 512 instead", "value", Logging::Loggable(newValue)));
g_outputBuffer = "setPayloadSizeOnSelfGeneratedAnswers() is set too low, using 512 instead!";
newValue = 512;
}
if (newValue > dnsdist::configuration::s_udpIncomingBufferSize) {
SLOG(warnlog("setPayloadSizeOnSelfGeneratedAnswers() is set too high, capping to %d instead!", dnsdist::configuration::s_udpIncomingBufferSize),
- dnsdist::logging::getTopLogger()->withName("configuration")->info(Logr::Warning, "Value passed to setPayloadSizeOnSelfGeneratedAnswers() is set too high, capping", "value", Logging::Loggable(newValue), "cap", Logging::Loggable(dnsdist::configuration::s_udpIncomingBufferSize)));
+ dnsdist::logging::getTopLogger("configuration")->info(Logr::Warning, "Value passed to setPayloadSizeOnSelfGeneratedAnswers() is set too high, capping", "value", Logging::Loggable(newValue), "cap", Logging::Loggable(dnsdist::configuration::s_udpIncomingBufferSize)));
g_outputBuffer = "setPayloadSizeOnSelfGeneratedAnswers() is set too high, capping to " + std::to_string(dnsdist::configuration::s_udpIncomingBufferSize) + " instead";
newValue = dnsdist::configuration::s_udpIncomingBufferSize;
}
catch (const std::exception& exp) {
g_outputBuffer = name + " cannot be used at runtime!\n";
SLOG(errlog("%s cannot be used at runtime!", name),
- dnsdist::logging::getTopLogger()->withName("configuration")->info(Logr::Error, "The " + name + " directive cannot be used at runtime"));
+ dnsdist::logging::getTopLogger("configuration")->info(Logr::Error, "The " + name + " directive cannot be used at runtime"));
}
});
}
catch (const std::exception& exp) {
g_outputBuffer = name + " cannot be used at runtime!\n";
SLOG(errlog("%s cannot be used at runtime!", name),
- dnsdist::logging::getTopLogger()->withName("configuration")->info(Logr::Error, "The " + name + " directive cannot be used at runtime"));
+ dnsdist::logging::getTopLogger("configuration")->info(Logr::Error, "The " + name + " directive cannot be used at runtime"));
}
});
}
if (value != 0 && value < item.minimumValue) {
g_outputBuffer = "Invalid value passed to " + name + "()!\n";
SLOG(errlog("Invalid value passed to %s()!", name),
- dnsdist::logging::getTopLogger()->withName("configuration")->info(Logr::Error, "Invalid value passed to " + name, "value", Logging::Loggable(value)));
+ dnsdist::logging::getTopLogger("configuration")->info(Logr::Error, "Invalid value passed to " + name, "value", Logging::Loggable(value)));
return;
}
catch (const std::exception& exp) {
g_outputBuffer = name + " cannot be used at runtime!\n";
SLOG(errlog("%s cannot be used at runtime!", name),
- dnsdist::logging::getTopLogger()->withName("configuration")->info(Logr::Error, "The " + name + " directive cannot be used at runtime"));
+ dnsdist::logging::getTopLogger("configuration")->info(Logr::Error, "The " + name + " directive cannot be used at runtime"));
}
setLuaSideEffect();
});
static std::shared_ptr<const Logr::Logger> getLogger(const std::string_view fromFunction)
{
- return dnsdist::logging::getTopLogger()->withName("lua-ffi-script")->withValues("lua.ffi.function", Logging::Loggable(fromFunction));
+ return dnsdist::logging::getTopLogger("lua-ffi-script")->withValues("lua.ffi.function", Logging::Loggable(fromFunction));
}
uint16_t dnsdist_ffi_dnsquestion_get_qtype(const dnsdist_ffi_dnsquestion_t* dq)
}
catch (const std::exception& exp) {
SLOG(warnlog("Error calling the Lua hook after new tickets key has been added: %s", exp.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Warning, exp.what(), "Error calling the Lua hook after a new ticket key has been added"));
+ dnsdist::logging::getTopLogger("ticket-keys-hook")->error(Logr::Warning, exp.what(), "Error calling the Lua hook after a new ticket key has been added"));
}
});
}
}
catch (const std::exception& exp) {
SLOG(errlog("addDynamicBlock: Unable to parse '%s': %s", clientIPStr, exp.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Error, exp.what(), "Unable to parse IP address when trying to add a dynamic rule", "address", Logging::Loggable(clientIPStr), "dnsdist.lua.function", Logging::Loggable("addDynamicBlock")));
+ dnsdist::logging::getTopLogger("addDynamicBlock")->error(Logr::Error, exp.what(), "Unable to parse IP address when trying to add a dynamic rule", "address", Logging::Loggable(clientIPStr), "dnsdist.lua.function", Logging::Loggable("addDynamicBlock")));
return;
}
catch (const PDNSException& exp) {
SLOG(errlog("addDynamicBlock: Unable to parse '%s': %s", clientIPStr, exp.reason),
- dnsdist::logging::getTopLogger()->error(Logr::Error, exp.reason, "Unable to parse IP address when trying to add a dynamic rule", "address", Logging::Loggable(clientIPStr), "dnsdist.lua.function", Logging::Loggable("addDynamicBlock")));
+ dnsdist::logging::getTopLogger("addDynamicBlock")->error(Logr::Error, exp.reason, "Unable to parse IP address when trying to add a dynamic rule", "address", Logging::Loggable(clientIPStr), "dnsdist.lua.function", Logging::Loggable("addDynamicBlock")));
return;
}
}
}
catch (const std::exception& e) {
VERBOSESLOG(infolog("Exception in the read callback of a NetworkListener: %s", e.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Info, e.what(), "Exception in the read callback of a NetworkListener"));
+ dnsdist::logging::getTopLogger("network-listener")->error(Logr::Info, e.what(), "Exception in the read callback of a NetworkListener"));
}
catch (...) {
VERBOSESLOG(infolog("Exception in the read callback of a NetworkListener"),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Unknown exception in the read callback of a NetworkListener"));
+ dnsdist::logging::getTopLogger("network-listener")->info(Logr::Info, "Unknown exception in the read callback of a NetworkListener"));
}
}
}
err = errno;
if (err != ENOENT) {
VERBOSESLOG(infolog("Error removing Unix socket to path '%s': %s", path, stringerror(err)),
- dnsdist::logging::getTopLogger()->error(Logr::Info, err, "Error removing unix socket when adding a listening endpoint to a NetworkListener", "path", Logging::Loggable(path)));
+ dnsdist::logging::getTopLogger("network-listener")->error(Logr::Info, err, "Error removing unix socket when adding a listening endpoint to a NetworkListener", "path", Logging::Loggable(path)));
}
}
}
}
if (suffixSeen) {
SLOG(warnlog("At least one parameter to %s has been parsed as a domain name amongst network masks, and will be ignored!", calledFrom),
- dnsdist::logging::getTopLogger()->info(Logr::Warning, "At least one parameter has been parsed as a domain name amongst network masks, and will be ignored!", "dnsdist.lua.function", Logging::Loggable(calledFrom)));
+ dnsdist::logging::getTopLogger("make-rule")->info(Logr::Warning, "At least one parameter has been parsed as a domain name amongst network masks, and will be ignored!", "dnsdist.lua.function", Logging::Loggable(calledFrom)));
}
return std::make_shared<NetmaskGroupRule>(nmg, true);
}
static std::shared_ptr<const Logr::Logger> getLogger(const std::string_view context)
{
- static auto logger = dnsdist::logging::getTopLogger()->withName("configuration");
+ static auto logger = dnsdist::logging::getTopLogger("configuration");
return logger->withValues("lua.function", Logging::Loggable(context));
}
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", "path", Logging::Loggable(config)));
+ dnsdist::logging::getTopLogger("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", "path", Logging::Loggable(config)));
+ dnsdist::logging::getTopLogger("lua-configuration")->info(Logr::Info, "Read configuration from file", "path", Logging::Loggable(config)));
}
luaCtx.executeCode(ifs);
}
catch (const std::exception& exp) {
SLOG(warnlog("Parsing Lua code '%s' in context '%s' failed: %s", code, context, exp.what()),
- dnsdist::logging::getTopLogger()->withName(context)->error(Logr::Warning, exp.what(), "Parsing Lua code failed", "lua_code", Logging::Loggable(code)));
+ dnsdist::logging::getTopLogger(context)->error(Logr::Warning, exp.what(), "Parsing Lua code failed", "lua_code", Logging::Loggable(code)));
}
return std::nullopt;
/* key is there but isn't compatible */
if (warnOnWrongType) {
SLOG(warnlog("Invalid type for key '%s' - ignored", key),
- dnsdist::logging::getTopLogger()->withName("configuration")->info(Logr::Warning, "Invalid type for key passed to Lua directive, ignored", "key", Logging::Loggable(key), "value", Logging::Loggable("value")));
+ dnsdist::logging::getTopLogger("configuration")->info(Logr::Warning, "Invalid type for key passed to Lua directive, ignored", "key", Logging::Loggable(key), "value", Logging::Loggable("value")));
vars->erase(key);
}
return -1;
}
catch (const std::exception& e) {
SLOG(warnlog("Parameter '%s' of '%s' must be integer, not '%s' - ignoring", func, key, valueStr),
- dnsdist::logging::getTopLogger()->withName(func)->info(Logr::Warning, "Invalid type for integer parameter, ignored", "key", Logging::Loggable(key), "value", Logging::Loggable("value")));
+ dnsdist::logging::getTopLogger(func)->info(Logr::Warning, "Invalid type for integer parameter, ignored", "key", Logging::Loggable(key), "value", Logging::Loggable("value")));
return -1;
}
}
}
for (const auto& [key, value] : *vars) {
SLOG(warnlog("%s: Unknown key '%s' given - ignored", func, key),
- dnsdist::logging::getTopLogger()->withName(func)->info(Logr::Warning, "Unknown key, ignored", "key", Logging::Loggable(key), "value", Logging::Loggable("value")));
+ dnsdist::logging::getTopLogger(func)->info(Logr::Warning, "Unknown key, ignored", "key", Logging::Loggable(key), "value", Logging::Loggable("value")));
}
}
static void dohClientThread(pdns::channel::Receiver<CrossProtocolQuery>&& receiver)
{
setThreadName("dnsdist/dohClie");
- auto logger = dnsdist::logging::getTopLogger()->withName("outgoing-doh-worker");
+ auto logger = dnsdist::logging::getTopLogger("outgoing-doh-worker");
try {
DoHClientThreadData data(std::move(receiver));
auto [sender, receiver] = pdns::channel::createObjectQueue<CrossProtocolQuery>(pdns::channel::SenderBlockingMode::SenderNonBlocking, pdns::channel::ReceiverBlockingMode::ReceiverNonBlocking, internalPipeBufferSize);
VERBOSESLOG(infolog("Adding DoH Client thread"),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Adding outgoing DoH worker thread"));
+ dnsdist::logging::getTopLogger("outgoing-doh")->info(Logr::Info, "Adding outgoing DoH worker thread"));
auto lock = std::scoped_lock(d_mutex);
if (d_numberOfThreads >= d_clientThreads.size()) {
VERBOSESLOG(infolog("Adding a new DoH client thread would exceed the vector size (%d/%d), skipping. Consider increasing the maximum amount of DoH client threads with setMaxDoHClientThreads() in the configuration.", d_numberOfThreads, d_clientThreads.size()),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Adding a new outgoing DoH worker thread would exceed the vector size, skipping. Consider increasing the maximum amount of DoH worker threads with setMaxDoHClientThreads() in the configuration.", "workers_count", Logging::Loggable(d_numberOfThreads), "workers_limit", Logging::Loggable(d_clientThreads.size())));
+ dnsdist::logging::getTopLogger("outgoing-doh")->info(Logr::Info, "Adding a new outgoing DoH worker thread would exceed the vector size, skipping. Consider increasing the maximum amount of DoH worker threads with setMaxDoHClientThreads() in the configuration.", "workers_count", Logging::Loggable(d_numberOfThreads), "workers_limit", Logging::Loggable(d_clientThreads.size())));
return;
}
catch (const std::runtime_error& e) {
/* the thread creation failed */
SLOG(errlog("Error creating a DoH thread: %s", e.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Error, e.what(), "Error creating an outgoing DoH worker thread"));
+ dnsdist::logging::getTopLogger("outgoing-doh")->error(Logr::Error, e.what(), "Error creating an outgoing DoH worker thread"));
return;
}
}
catch (const std::exception& e) {
SLOG(errlog("Error creating the DoH channel: %s", e.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Error, e.what(), "Error creating a channel for a new outgoing DoH worker"));
+ dnsdist::logging::getTopLogger("outgoing-doh")->error(Logr::Error, e.what(), "Error creating a channel for a new outgoing DoH worker"));
return;
}
#else /* HAVE_DNS_OVER_HTTPS && HAVE_NGHTTP2 */
}
catch (const std::exception& exp) {
VERBOSESLOG(infolog("Error while parsing the RRs from a response packet to add them to the protobuf message: %s", exp.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Info, exp.what(), "Error while parsing the RRs from a response packet to add them to the protobuf message"));
+ dnsdist::logging::getTopLogger("protobuf")->error(Logr::Info, exp.what(), "Error while parsing the RRs from a response packet to add them to the protobuf message"));
}
}
else {
if (used <= 0) {
++dnsdist::metrics::g_stats.proxyProtocolInvalid;
VERBOSESLOG(infolog("Ignoring invalid proxy protocol (%d, %d) query over %s from %s", query.size(), used, (isTCP ? "TCP" : "UDP"), remote.toStringWithPort()),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Ignoring invalid proxy protocol header", "dns.query.size", Logging::Loggable(query.size()), "proxy_protocol_parsed", Logging::Loggable(used), "protocol", Logging::Loggable(isTCP ? "TCP" : "UDP"), "network.peer.address", Logging::Loggable(remote)));
+ dnsdist::logging::getTopLogger("proxy-protocol")->info(Logr::Info, "Ignoring invalid proxy protocol header", "dns.query.size", Logging::Loggable(query.size()), "proxy_protocol_parsed", Logging::Loggable(used), "protocol", Logging::Loggable(isTCP ? "TCP" : "UDP"), "network.peer.address", Logging::Loggable(remote)));
return false;
}
if (static_cast<size_t>(used) > dnsdist::configuration::getCurrentRuntimeConfiguration().d_proxyProtocolMaximumSize) {
VERBOSESLOG(infolog("Proxy protocol header in %s packet from %s is larger than proxy-protocol-maximum-size (%d), dropping", (isTCP ? "TCP" : "UDP"), remote.toStringWithPort(), used),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Proxy protocol header is larger than proxy-protocol-maximum-size, dropping", "proxy_protocol_parsed", Logging::Loggable(used), "protocol", Logging::Loggable(isTCP ? "TCP" : "UDP"), "network.peer.address", Logging::Loggable(remote)));
+ dnsdist::logging::getTopLogger("proxy-protocol")->info(Logr::Info, "Proxy protocol header is larger than proxy-protocol-maximum-size, dropping", "proxy_protocol_parsed", Logging::Loggable(used), "protocol", Logging::Loggable(isTCP ? "TCP" : "UDP"), "network.peer.address", Logging::Loggable(remote)));
++dnsdist::metrics::g_stats.proxyProtocolInvalid;
return false;
}
if (proxyProto && dnsdist::configuration::getCurrentRuntimeConfiguration().d_applyACLToProxiedClients) {
if (!acl.match(realRemote)) {
VERBOSESLOG(infolog("Query from %s dropped because of ACL", realRemote.toStringWithPort()),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Query with proxy protocol header dropped because of ACL", "protocol", Logging::Loggable(isTCP ? "TCP" : "UDP"), "network.peer.address", Logging::Loggable(remote), "client.address", Logging::Loggable(realRemote)));
+ dnsdist::logging::getTopLogger("proxy-protocol")->info(Logr::Info, "Query with proxy protocol header dropped because of ACL", "protocol", Logging::Loggable(isTCP ? "TCP" : "UDP"), "network.peer.address", Logging::Loggable(remote), "client.address", Logging::Loggable(realRemote)));
++dnsdist::metrics::g_stats.aclDrops;
return false;
}
std::replace(queriedName.begin(), queriedName.end(), '+', '_');
std::replace(queriedName.begin(), queriedName.end(), '~', '_');
- auto logger = dnsdist::logging::getTopLogger()->withName("security-status-polling")->withValues("version", Logging::Loggable(pkgv), "dns.query.name", Logging::Loggable(queriedName));
+ auto logger = dnsdist::logging::getTopLogger("security-status-polling")->withValues("version", Logging::Loggable(pkgv), "dns.query.name", Logging::Loggable(queriedName));
try {
const std::string status = getSecPollStatus(*logger, queriedName);
{
if (statOID.size() != OID_LENGTH(queriesOID)) {
SLOG(errlog("Invalid OID for SNMP Counter64 statistic %s", name),
- dnsdist::logging::getTopLogger()->withName("snmp-agent")->info(Logr::Error, "Invalid OID for SNMP Counter64 metric", "metric_name", Logging::Loggable(name)));
+ dnsdist::logging::getTopLogger("snmp-agent")->info(Logr::Error, "Invalid OID for SNMP Counter64 metric", "metric_name", Logging::Loggable(name)));
return;
}
if (s_statsMap.find(statOID.at(statOID.size() - 1)) != s_statsMap.end()) {
SLOG(errlog("OID for SNMP Counter64 statistic %s has already been registered", name),
- dnsdist::logging::getTopLogger()->withName("snmp-agent")->info(Logr::Error, "OID for SNMP Counter64 metric has already been registered", "metric_name", Logging::Loggable(name)));
+ dnsdist::logging::getTopLogger("snmp-agent")->info(Logr::Error, "OID for SNMP Counter64 metric has already been registered", "metric_name", Logging::Loggable(name)));
return;
}
{
if (statOID.size() != OID_LENGTH(queriesOID)) {
SLOG(errlog("Invalid OID for SNMP Float statistic %s", name),
- dnsdist::logging::getTopLogger()->withName("snmp-agent")->info(Logr::Error, "Invalid OID for SNMP Float metric", "metric_name", Logging::Loggable(name)));
+ dnsdist::logging::getTopLogger("snmp-agent")->info(Logr::Error, "Invalid OID for SNMP Float metric", "metric_name", Logging::Loggable(name)));
return;
}
if (s_statsMap.find(statOID.at(statOID.size() - 1)) != s_statsMap.end()) {
SLOG(errlog("OID for SNMP Float statistic %s has already been registered", name),
- dnsdist::logging::getTopLogger()->withName("snmp-agent")->info(Logr::Error, "OID for SNMP Float metric has already been registered", "metric_name", Logging::Loggable(name)));
+ dnsdist::logging::getTopLogger("snmp-agent")->info(Logr::Error, "OID for SNMP Float metric has already been registered", "metric_name", Logging::Loggable(name)));
return;
}
{
if (statOID.size() != OID_LENGTH(queriesOID)) {
SLOG(errlog("Invalid OID for SNMP Gauge64 statistic %s", name),
- dnsdist::logging::getTopLogger()->withName("snmp-agent")->info(Logr::Error, "Invalid OID for SNMP Gauge64 metric", "metric_name", Logging::Loggable(name)));
+ dnsdist::logging::getTopLogger("snmp-agent")->info(Logr::Error, "Invalid OID for SNMP Gauge64 metric", "metric_name", Logging::Loggable(name)));
return;
}
if (s_statsMap.find(statOID.at(statOID.size() - 1)) != s_statsMap.end()) {
SLOG(errlog("OID for SNMP Gauge64 statistic %s has already been registered", name),
- dnsdist::logging::getTopLogger()->withName("snmp-agent")->info(Logr::Error, "OID for SNMP Gauge64 metric has already been registered", "metric_name", Logging::Loggable(name)));
+ dnsdist::logging::getTopLogger("snmp-agent")->info(Logr::Error, "OID for SNMP Gauge64 metric has already been registered", "metric_name", Logging::Loggable(name)));
return;
}
std::shared_ptr<const Logr::Logger> ConnectionToBackend::getLogger() const
{
- auto logger = dnsdist::logging::getTopLogger()->withName("outgoing-tcp-connection")->withValues("fresh_connection", Logging::Loggable(d_fresh), "tcp_fast_open", Logging::Loggable(d_enableFastOpen), "proxy_protocol_payload_sent", Logging::Loggable(d_proxyProtocolPayloadSent), "downstream_failures", Logging::Loggable(d_downstreamFailures), "highest_stream_id", Logging::Loggable(d_highestStreamID), "queries_count", Logging::Loggable(d_queries), "io_state", Logging::Loggable(d_ioState ? d_ioState->getState() : "empty"));
+ auto logger = dnsdist::logging::getTopLogger("outgoing-tcp-connection")->withValues("fresh_connection", Logging::Loggable(d_fresh), "tcp_fast_open", Logging::Loggable(d_enableFastOpen), "proxy_protocol_payload_sent", Logging::Loggable(d_proxyProtocolPayloadSent), "downstream_failures", Logging::Loggable(d_downstreamFailures), "highest_stream_id", Logging::Loggable(d_highestStreamID), "queries_count", Logging::Loggable(d_queries), "io_state", Logging::Loggable(d_ioState ? d_ioState->getState() : "empty"));
if (d_ds) {
logger = logger->withValues("backend.address", Logging::Loggable(d_ds->d_config.remote), "backend.name", Logging::Loggable(d_ds->getName()));
}
auto [crossProtocolResponseChannelSender, crossProtocolResponseChannelReceiver] = pdns::channel::createObjectQueue<TCPCrossProtocolResponse>(pdns::channel::SenderBlockingMode::SenderNonBlocking, pdns::channel::ReceiverBlockingMode::ReceiverNonBlocking, internalPipeBufferSize);
VERBOSESLOG(infolog("Adding TCP Client thread"),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Adding TCP worker thread to handle TCP connections from clients"));
+ dnsdist::logging::getTopLogger("incoming-tcp-worker")->info(Logr::Info, "Adding TCP worker thread to handle TCP connections from clients"));
if (d_numthreads >= d_tcpclientthreads.size()) {
VERBOSESLOG(infolog("Adding a new TCP client thread would exceed the vector size (%d/%d), skipping. Consider increasing the maximum amount of TCP client threads with setMaxTCPClientThreads() in the configuration.", d_numthreads.load(), d_tcpclientthreads.size()),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Adding a new TCP client thread would exceed the vector size, skipping. Consider increasing the maximum amount of TCP client threads with setMaxTCPClientThreads() in the configuration.", "workers_count", Logging::Loggable(d_numthreads.load()), "workers_limit", Logging::Loggable(d_tcpclientthreads.size())));
+ dnsdist::logging::getTopLogger("incoming-tcp-worker")->info(Logr::Info, "Adding a new TCP client thread would exceed the vector size, skipping. Consider increasing the maximum amount of TCP client threads with setMaxTCPClientThreads() in the configuration.", "workers_count", Logging::Loggable(d_numthreads.load()), "workers_limit", Logging::Loggable(d_tcpclientthreads.size())));
return;
}
}
catch (const std::runtime_error& e) {
SLOG(errlog("Error creating a TCP thread: %s", e.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Error, e.what(), "Error creating a TCP worker thread"));
+ dnsdist::logging::getTopLogger("incoming-tcp-worker")->error(Logr::Error, e.what(), "Error creating a TCP worker thread"));
return;
}
}
catch (const std::exception& e) {
SLOG(errlog("Error creating TCP worker: %s", e.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Error, e.what(), "Error creating a TCP worker"));
+ dnsdist::logging::getTopLogger("incoming-tcp-worker")->error(Logr::Error, e.what(), "Error creating a TCP worker"));
}
}
std::shared_ptr<const Logr::Logger> IncomingTCPConnectionState::getLogger() const
{
- return dnsdist::logging::getTopLogger()->withName("incoming-tcp-connection")->withValues("client.address", Logging::Loggable(d_proxiedRemote), "frontend.address", Logging::Loggable(d_ci.cs->local), "protocol", Logging::Loggable(d_ci.cs->getProtocol()), "network.peer.address", Logging::Loggable(d_ci.remote), "destination.address", Logging::Loggable(d_proxiedDestination));
+ return dnsdist::logging::getTopLogger("incoming-tcp-connection")->withValues("client.address", Logging::Loggable(d_proxiedRemote), "frontend.address", Logging::Loggable(d_ci.cs->local), "protocol", Logging::Loggable(d_ci.cs->getProtocol()), "network.peer.address", Logging::Loggable(d_ci.remote), "destination.address", Logging::Loggable(d_proxiedDestination));
}
static void handleIncomingTCPQuery(int pipefd, FDMultiplexer::funcparam_t& param)
from that point on */
setThreadName("dnsdist/tcpClie");
- auto logger = dnsdist::logging::getTopLogger()->withName("incoming-tcp-worker");
+ auto logger = dnsdist::logging::getTopLogger("incoming-tcp-worker");
try {
TCPClientThreadData data;
if (checkACL && !dnsdist::configuration::getCurrentRuntimeConfiguration().d_ACL.match(remote)) {
++dnsdist::metrics::g_stats.aclDrops;
VERBOSESLOG(infolog("Dropped TCP connection from %s because of ACL", remote.toStringWithPort()),
- dnsdist::logging::getTopLogger()->withName("incoming-tcp-worker")->info(Logr::Info, "Dropped TCP connection because of ACL", "frontend.address", Logging::Loggable(param.local), "client.address", Logging::Loggable(remote)));
+ dnsdist::logging::getTopLogger("incoming-tcp-worker")->info(Logr::Info, "Dropped TCP connection because of ACL", "frontend.address", Logging::Loggable(param.local), "client.address", Logging::Loggable(remote)));
return;
}
if (clientState.d_tcpConcurrentConnectionsLimit > 0 && concurrentConnections > clientState.d_tcpConcurrentConnectionsLimit) {
VERBOSESLOG(infolog("Dropped TCP connection from %s because of concurrent connections limit", remote.toStringWithPort()),
- dnsdist::logging::getTopLogger()->withName("incoming-tcp-worker")->info(Logr::Info, "Dropped TCP connection because of concurrent connections limit", "frontend.address", Logging::Loggable(param.local), "client.address", Logging::Loggable(remote)));
+ dnsdist::logging::getTopLogger("incoming-tcp-worker")->info(Logr::Info, "Dropped TCP connection because of concurrent connections limit", "frontend.address", Logging::Loggable(param.local), "client.address", Logging::Loggable(remote)));
return;
}
const auto maxTCPQueuedConnections = dnsdist::configuration::getImmutableConfiguration().d_maxTCPQueuedConnections;
if (maxTCPQueuedConnections > 0 && g_tcpclientthreads->getQueuedCount() >= maxTCPQueuedConnections) {
VERBOSESLOG(infolog("Dropping TCP connection from %s because we have too many queued already", remote.toStringWithPort()),
- dnsdist::logging::getTopLogger()->withName("incoming-tcp-worker")->info(Logr::Info, "Dropped TCP connection because we have too many queued already", "frontend.address", Logging::Loggable(param.local), "client.address", Logging::Loggable(remote)));
+ dnsdist::logging::getTopLogger("incoming-tcp-worker")->info(Logr::Info, "Dropped TCP connection because we have too many queued already", "frontend.address", Logging::Loggable(param.local), "client.address", Logging::Loggable(remote)));
return;
}
}
VERBOSESLOG(infolog("Got TCP connection from %s", remote.toStringWithPort()),
- dnsdist::logging::getTopLogger()->withName("incoming-tcp-worker")->info(Logr::Info, "Accepted new TCP connection", "frontend.address", Logging::Loggable(param.local), "client.address", Logging::Loggable(remote)));
+ dnsdist::logging::getTopLogger("incoming-tcp-worker")->info(Logr::Info, "Accepted new TCP connection", "frontend.address", Logging::Loggable(param.local), "client.address", Logging::Loggable(remote)));
connInfo.remote = remote;
}
catch (const std::exception& e) {
SLOG(errlog("While reading a TCP question: %s", e.what()),
- dnsdist::logging::getTopLogger()->withName("incoming-tcp-worker")->error(Logr::Error, e.what(), "Error while accepting a TCP connection", "frontend.address", Logging::Loggable(param.local)));
+ dnsdist::logging::getTopLogger("incoming-tcp-worker")->error(Logr::Error, e.what(), "Error while accepting a TCP connection", "frontend.address", Logging::Loggable(param.local)));
if (tcpClientCountIncremented) {
dnsdist::IncomingConcurrentTCPConnectionsManager::accountClosedTCPConnection(remote);
}
void WebserverThread(ComboAddress listeningAddress, Socket sock)
{
setThreadName("dnsdist/webserv");
- auto serverLogger = dnsdist::logging::getTopLogger()->withName("webserver")->withValues("network.local.address", Logging::Loggable(listeningAddress));
+ auto serverLogger = dnsdist::logging::getTopLogger("webserver")->withValues("network.local.address", Logging::Loggable(listeningAddress));
SLOG(infolog("Webserver launched on %s", listeningAddress.toStringWithPort()),
serverLogger->info(Logr::Info, "Webserver launched"));
{
try {
setThreadName("dnsdist/XskResp");
- auto logger = dnsdist::logging::getTopLogger()->withName("xsk-response-worker")->withValues("backend.name", Logging::Loggable(dss->getName()), "backend.address", Logging::Loggable(dss->d_config.remote));
+ auto logger = dnsdist::logging::getTopLogger("xsk-response-worker")->withValues("backend.name", Logging::Loggable(dss->getName()), "backend.address", Logging::Loggable(dss->d_config.remote));
auto pollfds = getPollFdsForWorker(*xskInfo);
while (!dss->isStopped()) {
}
catch (const std::exception& e) {
SLOG(errlog("XSK responder thread died because of exception: %s", e.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Error, e.what(), "XSK responder thread died because of exception"));
+ dnsdist::logging::getTopLogger("xsk-response-worker")->error(Logr::Error, e.what(), "XSK responder thread died because of exception"));
}
catch (const PDNSException& e) {
SLOG(errlog("XSK responder thread died because of PowerDNS exception: %s", e.reason),
- dnsdist::logging::getTopLogger()->error(Logr::Error, e.reason, "XSK responder thread died because of exception"));
+ dnsdist::logging::getTopLogger("xsk-response-worker")->error(Logr::Error, e.reason, "XSK responder thread died because of exception"));
}
catch (...) {
SLOG(errlog("XSK responder thread died because of an unknown exception"),
- dnsdist::logging::getTopLogger()->info(Logr::Error, "XSK responder thread died because of an unknown exception"));
+ dnsdist::logging::getTopLogger("xsk-response-worker")->info(Logr::Error, "XSK responder thread died because of an unknown exception"));
}
}
expectProxyProtocol = expectProxyProtocolFrom(from);
if (!dnsdist::configuration::getCurrentRuntimeConfiguration().d_ACL.match(from) && !expectProxyProtocol) {
VERBOSESLOG(infolog("Query from %s dropped because of ACL", from.toStringWithPort()),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Query dropped because of ACL", "client.address", Logging::Loggable(from)));
+ dnsdist::logging::getTopLogger("xsk-frontend-worker")->info(Logr::Info, "Query dropped because of ACL", "client.address", Logging::Loggable(from)));
++dnsdist::metrics::g_stats.aclDrops;
return false;
}
void XskRouter(std::shared_ptr<XskSocket> xsk)
{
setThreadName("dnsdist/XskRouter");
- auto logger = dnsdist::logging::getTopLogger()->withName("xsk-router");
+ auto logger = dnsdist::logging::getTopLogger("xsk-router");
uint32_t failed = 0;
// packets to be submitted for sending
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", "client.address", Logging::Loggable(dest)));
+ dnsdist::logging::getTopLogger("sendfromto")->error(error, "Error sending UDP response", "client.address", Logging::Loggable(dest)));
}
return;
}
}
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), "client.address", Logging::Loggable(dest)));
+ dnsdist::logging::getTopLogger("sendfromto")->error(exp.what(), "Error sending UDP response", "source.address", Logging::Loggable(from), "client.address", Logging::Loggable(dest)));
}
}
catch (const std::exception& e) {
if (remote && !response.empty() && static_cast<size_t>(response.size()) > sizeof(dnsheader)) {
VERBOSESLOG(infolog("Backend %s sent us a response with id %d that did not parse: %s", remote->d_config.remote.toStringWithPort(), ntohs(dnsHeader->id), e.what()),
- dnsdist::logging::getTopLogger()->withName("udp-response-worker")->error(e.what(), "Received a DNS response from a backend that we could not parse", "backend.address", Logging::Loggable(remote->d_config.remote), "dns.query.id", Logging::Loggable(ntohs(dnsHeader->id))));
+ dnsdist::logging::getTopLogger("udp-response-worker")->error(e.what(), "Received a DNS response from a backend that we could not parse", "backend.address", Logging::Loggable(remote->d_config.remote), "dns.query.id", Logging::Loggable(ntohs(dnsHeader->id))));
}
++dnsdist::metrics::g_stats.nonCompliantResponses;
if (remote) {
}
else {
SLOG(warnlog("Error rewriting content"),
- dnsdist::logging::getTopLogger()->withName("fixup-response")->info(Logr::Error, "Error rewriting response content", "dns.question.name", Logging::Loggable(qname)));
+ dnsdist::logging::getTopLogger("fixup-response")->info(Logr::Error, "Error rewriting response content", "dns.question.name", Logging::Loggable(qname)));
}
}
}
}
else {
SLOG(warnlog("Error rewriting content"),
- dnsdist::logging::getTopLogger()->withName("fixup-response")->info(Logr::Error, "Error rewriting response content", "dns.question.name", Logging::Loggable(qname)));
+ dnsdist::logging::getTopLogger("fixup-response")->info(Logr::Error, "Error rewriting response content", "dns.question.name", Logging::Loggable(qname)));
}
}
}
if (res != 0) {
/* dropping response */
VERBOSESLOG(infolog("Error encrypting the response, dropping."),
- dnsdist::logging::getTopLogger()->withName("dnscrypt")->info(Logr::Error, "Error encrypting response, dropping"));
+ dnsdist::logging::getTopLogger("dnscrypt")->info(Logr::Error, "Error encrypting response, dropping"));
return false;
}
}
// listens on a dedicated socket, lobs answers from downstream servers to original requestors
void responderThread(std::shared_ptr<DownstreamState> dss)
{
- auto responderLogger = dnsdist::logging::getTopLogger()->withName("udp-response")->withValues("backend.address", Logging::Loggable(dss->d_config.remote));
+ auto responderLogger = dnsdist::logging::getTopLogger("udp-response")->withValues("backend.address", Logging::Loggable(dss->d_config.remote));
try {
setThreadName("dnsdist/respond");
if (result == -1) {
int savederrno = errno;
VERBOSESLOG(infolog("Error sending request to backend %s: %s", backend->d_config.remote.toStringWithPort(), stringerror(savederrno)),
- dnsdist::logging::getTopLogger()->error(savederrno, "Error sending request to the backend", "backend.address", Logging::Loggable(backend->d_config.remote)));
+ dnsdist::logging::getTopLogger("udp-frontend")->error(savederrno, "Error sending request to the backend", "backend.address", Logging::Loggable(backend->d_config.remote)));
/* This might sound silly, but on Linux send() might fail with EINVAL
if the interface the socket was bound to doesn't exist anymore.
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", "client.address", Logging::Loggable(remote), "destination.address", Logging::Loggable(dest), "frontend.address", Logging::Loggable(clientState.local)));
+ dnsdist::logging::getTopLogger("udp-query")->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;
expectProxyProtocol = clientState.d_enableProxyProtocol && expectProxyProtocolFrom(remote);
if (!dnsdist::configuration::getCurrentRuntimeConfiguration().d_ACL.match(remote) && !expectProxyProtocol) {
VERBOSESLOG(infolog("Query from %s dropped because of ACL", remote.toStringWithPort()),
- dnsdist::logging::getTopLogger()->info("Query dropped because of ACL", "source.address", Logging::Loggable(dest)));
+ dnsdist::logging::getTopLogger("udp-query")->info("Query dropped because of ACL", "source.address", Logging::Loggable(dest)));
++dnsdist::metrics::g_stats.aclDrops;
return false;
}
}
catch (const std::exception& exp) {
SLOG(warnlog("Error calling the Lua hook for Server State Change: %s", exp.what()),
- dnsdist::logging::getTopLogger()->error(exp.what(), "Error calling the Lua hook for backend state change", "backend.name", Logging::Loggable(nameWithAddr)));
+ dnsdist::logging::getTopLogger("backend-state-update")->error(exp.what(), "Error calling the Lua hook for backend state change", "backend.name", Logging::Loggable(nameWithAddr)));
}
}
}
catch (const std::exception& e) {
VERBOSESLOG(infolog("Got an error in UDP question thread while parsing a query from %s, id %d: %s", ids.origRemote.toStringWithPort(), queryId, e.what()),
- dnsdist::logging::getTopLogger()->error(e.what(), "Got an error in UDP question thread while parsing a query", "source.address", Logging::Loggable(ids.origRemote), "dns.question.id", Logging::Loggable(queryId)));
+ dnsdist::logging::getTopLogger("udp-frontend")->error(e.what(), "Got an error in UDP question thread while parsing a query", "source.address", Logging::Loggable(ids.origRemote), "dns.question.id", Logging::Loggable(queryId)));
}
}
}
catch (const std::exception& e) {
VERBOSESLOG(infolog("Got an error in UDP question thread while parsing a query from %s, id %d: %s", ids.origRemote.toStringWithPort(), queryId, e.what()),
- dnsdist::logging::getTopLogger()->error(e.what(), "Got an error in XSK UDP question thread while parsing a query", "source.address", Logging::Loggable(ids.origRemote), "dns.question.id", Logging::Loggable(queryId)));
+ dnsdist::logging::getTopLogger("udp-xsk-frontend")->error(e.what(), "Got an error in XSK UDP question thread while parsing a query", "source.address", Logging::Loggable(ids.origRemote), "dns.question.id", Logging::Loggable(queryId)));
}
return false;
}
if (msgsGot <= 0) {
int savederrno = errno;
VERBOSESLOG(infolog("Getting UDP messages via recvmmsg() failed with: %s", stringerror(savederrno)),
- dnsdist::logging::getTopLogger()->error(savederrno, "Getting UDP messages via recvmmsg failed", "frontend.address", Logging::Loggable(clientState->local)));
+ dnsdist::logging::getTopLogger("udp-recvmmsg-frontend")->error(savederrno, "Getting UDP messages via recvmmsg failed", "frontend.address", Logging::Loggable(clientState->local)));
msgsGot = 0;
continue;
}
if (sent < 0 || static_cast<unsigned int>(sent) != msgsToSend) {
int savederrno = errno;
VERBOSESLOG(infolog("Error sending responses with sendmmsg() (%d on %u): %s", sent, msgsToSend, stringerror(savederrno)),
- dnsdist::logging::getTopLogger()->error(savederrno, "Error sending responses with sendmmsg()", "address", Logging::Loggable(clientState->local), "dnsdist.sendmmsg.messages_sent", Logging::Loggable(sent), "dnsdist.sendmmsg.messages_to_send", Logging::Loggable(msgsToSend)));
+ dnsdist::logging::getTopLogger("udp-sendmmsg-frontend")->error(savederrno, "Error sending responses with sendmmsg()", "address", Logging::Loggable(clientState->local), "dnsdist.sendmmsg.messages_sent", Logging::Loggable(sent), "dnsdist.sendmmsg.messages_to_send", Logging::Loggable(msgsToSend)));
}
}
}
}
catch (const std::exception& e) {
SLOG(errlog("UDP client thread died because of exception: %s", e.what()),
- dnsdist::logging::getTopLogger()->error(e.what(), "UDP client thread died because of exception"));
+ dnsdist::logging::getTopLogger("udp-frontend")->error(e.what(), "UDP client thread died because of exception"));
}
catch (const PDNSException& e) {
SLOG(errlog("UDP client thread died because of PowerDNS exception: %s", e.reason),
- dnsdist::logging::getTopLogger()->error(e.reason, "UDP client thread died because of PowerDNS exception"));
+ dnsdist::logging::getTopLogger("udp-frontend")->error(e.reason, "UDP client thread died because of PowerDNS exception"));
}
catch (...) {
SLOG(errlog("UDP client thread died because of an exception: unknown"),
- dnsdist::logging::getTopLogger()->info(Logr::Error, "UDP client thread died because of an unknown exception"));
+ dnsdist::logging::getTopLogger("udp-frontend")->info(Logr::Error, "UDP client thread died because of an unknown exception"));
}
}
catch (const std::exception& e) {
if (secondsToWaitLog <= 0) {
SLOG(warnlog("Error during execution of maintenance function(s): %s", e.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Warning, e.what(), "Error during execution of maintenance function(s)"));
+ dnsdist::logging::getTopLogger("maintenance")->error(Logr::Warning, e.what(), "Error during execution of maintenance function(s)"));
secondsToWaitLog = 61;
}
secondsToWaitLog -= interval;
}
catch (const std::exception& exp) {
VERBOSESLOG(infolog("Exception in the health-check thread: %s", exp.what()),
- dnsdist::logging::getTopLogger()->error(exp.what(), "Exception in the health-check thread"));
+ dnsdist::logging::getTopLogger("health-check")->error(exp.what(), "Exception in the health-check thread"));
}
}
}
-static void bindAny([[maybe_unused]] int addressFamily, [[maybe_unused]] int sock, [[maybe_unused]] const std::shared_ptr<Logr::Logger>& logger)
+static void bindAny([[maybe_unused]] int addressFamily, [[maybe_unused]] int sock, [[maybe_unused]] const std::shared_ptr<const Logr::Logger>& logger)
{
__attribute__((unused)) int one = 1;
if (setgid(gid) == 0) {
if (setgroups(0, nullptr) < 0) {
SLOG(warnlog("Warning: Unable to drop supplementary gids: %s", stringerror()),
- dnsdist::logging::getTopLogger()->error(Logr::Warning, stringerror(), "Warning: Unable to drop supplementary gids"));
+ dnsdist::logging::getTopLogger("setup")->error(Logr::Warning, stringerror(), "Warning: Unable to drop supplementary gids"));
}
}
else {
SLOG(warnlog("Warning: Unable to set group ID to %d: %s", gid, stringerror()),
- dnsdist::logging::getTopLogger()->error(Logr::Warning, stringerror(), "Warning: Unable to set group ID", "systemd.gid", Logging::Loggable(gid)));
+ dnsdist::logging::getTopLogger("setup")->error(Logr::Warning, stringerror(), "Warning: Unable to set group ID", "systemd.gid", Logging::Loggable(gid)));
}
}
}
if (uid != 0) {
if (setuid(uid) < 0) {
SLOG(warnlog("Warning: Unable to set user ID to %d: %s", uid, stringerror()),
- dnsdist::logging::getTopLogger()->error(Logr::Warning, stringerror(), "Warning: Unable to set user ID", "system.uid", Logging::Loggable(uid)));
+ dnsdist::logging::getTopLogger("setup")->error(Logr::Warning, stringerror(), "Warning: Unable to set user ID", "system.uid", Logging::Loggable(uid)));
}
}
}
getrlimit(RLIMIT_NOFILE, &resourceLimits);
if (resourceLimits.rlim_cur <= requiredFDsCount) {
SLOG(warnlog("Warning, this configuration can use more than %d file descriptors, web server and console connections not included, and the current limit is %d.", std::to_string(requiredFDsCount), std::to_string(resourceLimits.rlim_cur)),
- dnsdist::logging::getTopLogger()->info(Logr::Warning, "Warning, this configuration can use more file descriptors, web server and console connections not included, than the currently configured limit", "system.required_file_descriptors", Logging::Loggable(requiredFDsCount), "system.file_descriptors_limit", Logging::Loggable(resourceLimits.rlim_cur)));
+ dnsdist::logging::getTopLogger("setup")->info(Logr::Warning, "Warning, this configuration can use more file descriptors, web server and console connections not included, than the currently configured limit", "system.required_file_descriptors", Logging::Loggable(requiredFDsCount), "system.file_descriptors_limit", Logging::Loggable(resourceLimits.rlim_cur)));
#ifdef HAVE_SYSTEMD
SLOG(warnlog("You can increase this value by using LimitNOFILE= in the systemd unit file or ulimit."),
- dnsdist::logging::getTopLogger()->info(Logr::Warning, "You can increase this value by using LimitNOFILE= in the systemd unit file over ulimit"));
+ dnsdist::logging::getTopLogger("setup")->info(Logr::Warning, "You can increase this value by using LimitNOFILE= in the systemd unit file over ulimit"));
#else
SLOG(warnlog("You can increase this value by using ulimit."),
- dnsdist::logging::getTopLogger()->info(Logr::Warning, "You can increase this value by using ulimit."));
+ dnsdist::logging::getTopLogger("setup")->info(Logr::Warning, "You can increase this value by using ulimit."));
#endif
}
}
-static void setupLocalSocket(ClientState& clientState, const ComboAddress& addr, int& socket, bool tcp, bool warn, const std::shared_ptr<Logr::Logger>& logger)
+static void setupLocalSocket(ClientState& clientState, const ComboAddress& addr, int& socket, bool tcp, bool warn, const std::shared_ptr<const Logr::Logger>& logger)
{
const auto& immutableConfig = dnsdist::configuration::getImmutableConfiguration();
static bool s_warned_ipv6_recvpktinfo = false;
}
}
-static void setUpLocalBind(ClientState& cstate, const std::shared_ptr<Logr::Logger>& logger)
+static void setUpLocalBind(ClientState& cstate, const std::shared_ptr<const Logr::Logger>& logger)
{
/* skip some warnings if there is an identical UDP context */
bool warn = !cstate.tcp || cstate.tlsFrontend != nullptr || cstate.dohFrontend != nullptr;
config = std::move(newConfig);
});
}
-static void setupPools(const std::shared_ptr<Logr::Logger>& logger)
+static void setupPools(const std::shared_ptr<const Logr::Logger>& logger)
{
bool precompute = false;
const auto& currentConfig = dnsdist::configuration::getCurrentRuntimeConfiguration();
if (getegid() != newgid) {
if (running_in_service_mgr()) {
SLOG(errlog("--gid/-g set on command-line, but dnsdist was started as a systemd service. Use the 'Group' setting in the systemd unit file to set the group to run as"),
- dnsdist::logging::getTopLogger()->info(Logr::Error, "--gid/-g set on command-line, but dnsdist was started as a systemd service. Use the 'Group' setting in the systemd unit file to set the group to run as"));
+ dnsdist::logging::getTopLogger("setup")->info(Logr::Error, "--gid/-g set on command-line, but dnsdist was started as a systemd service. Use the 'Group' setting in the systemd unit file to set the group to run as"));
_exit(EXIT_FAILURE);
}
dropGroupPrivs(newgid);
if (geteuid() != newuid) {
if (running_in_service_mgr()) {
SLOG(errlog("--uid/-u set on command-line, but dnsdist was started as a systemd service. Use the 'User' setting in the systemd unit file to set the user to run as"),
- dnsdist::logging::getTopLogger()->info(Logr::Error, "--uid/-u set on command-line, but dnsdist was started as a systemd service. Use the 'User' setting in the systemd unit file to set the user to run as"));
+ dnsdist::logging::getTopLogger("setup")->info(Logr::Error, "--uid/-u set on command-line, but dnsdist was started as a systemd service. Use the 'User' setting in the systemd unit file to set the user to run as"));
_exit(EXIT_FAILURE);
}
dropUserPrivs(newuid);
}
catch (const std::exception& e) {
SLOG(warnlog("%s", e.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Warning, e.what(), "Error while dropping capabilities"));
+ dnsdist::logging::getTopLogger("setup")->error(Logr::Warning, e.what(), "Error while dropping capabilities"));
}
}
}
catch (const std::exception& exp) {
SLOG(errlog("Unable to bind to control socket on %s: %s", local.toStringWithPort(), exp.what()),
- dnsdist::logging::getTopLogger()->error(exp.what(), "Unable to bind to console control socket", "network.local.address", Logging::Loggable(local)));
+ dnsdist::logging::getTopLogger("setup")->error(exp.what(), "Unable to bind to console control socket", "network.local.address", Logging::Loggable(local)));
}
}
}
catch (const std::exception& exp) {
SLOG(errlog("Unable to bind to web server socket on %s: %s", local.toStringWithPort(), exp.what()),
- dnsdist::logging::getTopLogger()->error(exp.what(), "Unable to bind to web server socket", "network.local.address", Logging::Loggable(local)));
+ dnsdist::logging::getTopLogger("setup")->error(exp.what(), "Unable to bind to web server socket", "network.local.address", Logging::Loggable(local)));
}
}
return tentativeFile;
}
-static bool loadConfigurationFromFile(const std::string& configurationFile, bool isClient, bool configCheck, const std::shared_ptr<Logr::Logger>& logger)
+static bool loadConfigurationFromFile(const std::string& configurationFile, bool isClient, bool configCheck, const std::shared_ptr<const Logr::Logger>& logger)
{
if (boost::ends_with(configurationFile, ".yml")) {
// the bindings are always needed, for example for inline Lua
/* for now, we will create the correct backend after parsing the configuration */
dnsdist::logging::setup("");
- auto setupLogger = dnsdist::logging::getTopLogger()->withName("setup");
+ auto setupLogger = dnsdist::logging::getTopLogger("setup");
openlog("dnsdist", LOG_PID | LOG_NDELAY, LOG_DAEMON);
if (cmdLine.useStructuredLogging && !cmdLine.structuredLoggingBackend.empty()) {
dnsdist::logging::setup(cmdLine.structuredLoggingBackend);
- setupLogger = dnsdist::logging::getTopLogger()->withName("setup");
+ setupLogger = dnsdist::logging::getTopLogger("setup");
}
dnsdist::configuration::updateRuntimeConfiguration([](dnsdist::configuration::RuntimeConfiguration& config) {
}
// No exception was thrown
dnsdist::logging::setup(dnsdist::configuration::getImmutableConfiguration().d_loggingBackend);
- setupLogger = dnsdist::logging::getTopLogger()->withName("setup");
+ setupLogger = dnsdist::logging::getTopLogger("setup");
SLOG(infolog("Configuration '%s' OK!", cmdLine.config),
setupLogger->info(Logr::Info, "Configuration OK", "path", Logging::Loggable(cmdLine.config)));
}
dnsdist::logging::setup(dnsdist::configuration::getImmutableConfiguration().d_loggingBackend);
- setupLogger = dnsdist::logging::getTopLogger()->withName("setup");
+ setupLogger = dnsdist::logging::getTopLogger("setup");
// we only want to update this value if it has not been set by either the Lua or YAML configuration,
// and we need to stop touching this value once the backends' hashes have been computed, in setupPools()
catch (const LuaContext::ExecutionErrorException& e) {
try {
SLOG(errlog("Fatal Lua error: %s", e.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Error, e.what(), "Fatal Lua error"));
+ dnsdist::logging::getTopLogger("main")->error(Logr::Error, e.what(), "Fatal Lua error"));
std::rethrow_if_nested(e);
}
catch (const std::exception& ne) {
SLOG(errlog("Details: %s", ne.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Error, ne.what(), "Additional details for fatal Lua error"));
+ dnsdist::logging::getTopLogger("main")->error(Logr::Error, ne.what(), "Additional details for fatal Lua error"));
}
catch (const PDNSException& ae) {
SLOG(errlog("Fatal pdns error: %s", ae.reason),
- dnsdist::logging::getTopLogger()->error(Logr::Error, ae.reason, "Additional PowerDNS details for fatal Lua error"));
+ dnsdist::logging::getTopLogger("main")->error(Logr::Error, ae.reason, "Additional PowerDNS details for fatal Lua error"));
}
doExitNicely(EXIT_FAILURE);
}
catch (const std::exception& e) {
SLOG(errlog("Fatal error: %s", e.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Error, e.what(), "Fatal error"));
+ dnsdist::logging::getTopLogger("main")->error(Logr::Error, e.what(), "Fatal error"));
doExitNicely(EXIT_FAILURE);
}
catch (const PDNSException& ae) {
SLOG(errlog("Fatal pdns error: %s", ae.reason),
- dnsdist::logging::getTopLogger()->error(Logr::Error, ae.reason, "Fatal PowerDNS error"));
+ dnsdist::logging::getTopLogger("main")->error(Logr::Error, ae.reason, "Fatal PowerDNS error"));
doExitNicely(EXIT_FAILURE);
}
}
if (!unit->dsc->d_responseSender.send(std::move(unit))) {
++dnsdist::metrics::g_stats.doh3ResponsePipeFull;
VERBOSESLOG(infolog("Unable to pass a %s to the DoH3 worker thread because the pipe is full", description),
- dnsdist::logging::getTopLogger()->info(Logr::Info, std::string("Unable to pass a ") + std::string(description) + " to the DoH3 worker thread because the pipe is full"));
+ dnsdist::logging::getTopLogger("doh3")->info(Logr::Info, std::string("Unable to pass a ") + std::string(description) + " to the DoH3 worker thread because the pipe is full"));
}
}
catch (const std::exception& e) {
VERBOSESLOG(infolog("Unable to pass a %s to the DoH3 worker thread because we couldn't write to the pipe: %s", description, e.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Info, e.what(), std::string("Unable to pass a ") + std::string(description) + " to the DoH3 worker thread because we couldn't write to the pipe"));
+ dnsdist::logging::getTopLogger("doh3")->error(Logr::Info, e.what(), std::string("Unable to pass a ") + std::string(description) + " to the DoH3 worker thread because we couldn't write to the pipe"));
}
}
{
try {
std::shared_ptr<DOH3Frontend>& frontend = clientState->doh3Frontend;
- auto frontendLogger = dnsdist::logging::getTopLogger()->withName("doh3-frontend")->withValues("frontend.address", Logging::Loggable(clientState->local));
+ auto frontendLogger = dnsdist::logging::getTopLogger("doh3-frontend")->withValues("frontend.address", Logging::Loggable(clientState->local));
frontend->d_server_config->clientState = clientState;
frontend->d_server_config->df = clientState->doh3Frontend;
}
catch (const std::exception& exp) {
VERBOSESLOG(infolog("Error while minting DoH3 token: %s", exp.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Info, exp.what(), "Error while minting DoH3 token"));
+ dnsdist::logging::getTopLogger("doh3")->error(Logr::Info, exp.what(), "Error while minting DoH3 token"));
throw;
}
}
}
catch (const std::exception& exp) {
VERBOSESLOG(infolog("Error while validating DoH3 token: %s", exp.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Info, exp.what(), "Error while validating DoH3 token"));
+ dnsdist::logging::getTopLogger("doh3")->error(Logr::Info, exp.what(), "Error while validating DoH3 token"));
return std::nullopt;
}
}
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()), "client.address", Logging::Loggable(peer)));
+ dnsdist::logging::getTopLogger("quic-send-from-to")->error(Logr::Info, error, "Error while sending QUIC datagram", "datagram_size", Logging::Loggable(buffer.size()), "client.address", Logging::Loggable(peer)));
}
return;
}
}
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), "client.address", Logging::Loggable(peer)));
+ dnsdist::logging::getTopLogger("quic-send-from-to")->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)));
}
}
if (!unit->dsc->d_responseSender.send(std::move(unit))) {
++dnsdist::metrics::g_stats.doqResponsePipeFull;
VERBOSESLOG(infolog("Unable to pass a %s to the DoQ worker thread because the pipe is full", description),
- dnsdist::logging::getTopLogger()->info(Logr::Info, std::string("Unable to pass a ") + std::string(description) + " to the DoQ worker thread because the pipe is full"));
+ dnsdist::logging::getTopLogger("doq")->info(Logr::Info, std::string("Unable to pass a ") + std::string(description) + " to the DoQ worker thread because the pipe is full"));
}
}
catch (const std::exception& e) {
VERBOSESLOG(infolog("Unable to pass a %s to the DoQ worker thread because we couldn't write to the pipe: %s", description, e.what()),
- dnsdist::logging::getTopLogger()->error(Logr::Info, e.what(), std::string("Unable to pass a ") + std::string(description) + " to the DoQ worker thread because we couldn't write to the pipe"));
+ dnsdist::logging::getTopLogger("doq")->error(Logr::Info, e.what(), std::string("Unable to pass a ") + std::string(description) + " to the DoQ worker thread because we couldn't write to the pipe"));
}
}
{
try {
std::shared_ptr<DOQFrontend>& frontend = clientState->doqFrontend;
- auto frontendLogger = dnsdist::logging::getTopLogger()->withName("doq-frontend")->withValues("frontend.address", Logging::Loggable(clientState->local));
+ auto frontendLogger = dnsdist::logging::getTopLogger("doq-frontend")->withValues("frontend.address", Logging::Loggable(clientState->local));
frontend->d_server_config->clientState = clientState;
frontend->d_server_config->df = clientState->doqFrontend;
}
catch (const std::exception& e) {
SLOG(infolog("Error parsing the status header for stream ID %d: %s", frame->hd.stream_id, e.what()),
- dnsdist::logging::getTopLogger()->error(e.what(), "Error parsing the status header for stream", "http.stream_id", Logging::Loggable(frame->hd.stream_id)));
+ dnsdist::logging::getTopLogger("nghttp2-incoming-unit-tests")->error(e.what(), "Error parsing the status header for stream", "http.stream_id", Logging::Loggable(frame->hd.stream_id)));
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
}
g_slog->withName("protobuf")->error(Logr::Error, e.what(), "Exception while connecting to remote logger", "address", Logging::Loggable(d_remote)));
#else
SLOG(warnlog("Error connecting to remote logger %s: %s", d_remote.toStringWithPort(), e.what()),
- dnsdist::logging::getTopLogger()->withName("protobuf")->error(e.what(), "Exception while connecting to remote logger", "address", Logging::Loggable(d_remote))
+ dnsdist::logging::getTopLogger("protobuf")->error(e.what(), "Exception while connecting to remote logger", "address", Logging::Loggable(d_remote))
);
#endif
g_slog->withName("protobuf")->error(Logr::Error, e.what(), "Remote Logger's maintenance thread died"));
#else
SLOG(errlog("Remote Logger's maintenance thread died on: %s", e.what()),
- dnsdist::logging::getTopLogger()->withName("protobuf")->error(e.what(), "Remote Logger's maintenance thread died")
+ dnsdist::logging::getTopLogger("protobuf")->error(e.what(), "Remote Logger's maintenance thread died")
);
#endif
}
g_slog->withName("protobuf")->info(Logr::Error, "Remote Logger's maintenance thread died"));
#else
SLOG(errlog("Remote Logger's maintenance thread died on: %s"),
- dnsdist::logging::getTopLogger()->withName("protobuf")->info(Logr::Error, "Remote Logger's maintenance thread died")
+ dnsdist::logging::getTopLogger("protobuf")->info(Logr::Error, "Remote Logger's maintenance thread died")
);
#endif
}
for (const auto& warning : warnings) {
#if defined(DNSDIST)
SLOG(warnlog("%s", warning),
- dnsdist::logging::getTopLogger()->info(Logr::Warning, warning));
+ dnsdist::logging::getTopLogger("openssl-frontend")->info(Logr::Warning, warning));
#else /* DNSDIST */
warnlog("%s", warning);
#endif /* DNSDIST */
if (!d_conn) {
VERBOSESLOG(infolog("Error creating TLS object"),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Error creating server-side TLS object"));
+ dnsdist::logging::getTopLogger("openssl-server-side")->info(Logr::Info, "Error creating server-side TLS object"));
if (shouldDoVerboseLogging()) {
ERR_print_errors_fp(stderr);
}
if (!d_conn) {
VERBOSESLOG(infolog("Error creating TLS object"),
- dnsdist::logging::getTopLogger()->info(Logr::Info, "Error creating client-side TLS object"));
+ dnsdist::logging::getTopLogger("openssl-client-side")->info(Logr::Info, "Error creating client-side TLS object"));
if (shouldDoVerboseLogging()) {
ERR_print_errors_fp(stderr);
}
#if (OPENSSL_VERSION_NUMBER < 0x10002000L)
#if defined(DNSDIST)
SLOG(warnlog("TLS hostname validation requested but not supported for OpenSSL < 1.0.2"),
- dnsdist::logging::getTopLogger()->info(Logr::Warning, "TLS hostname validation requested but not supported for OpenSSL < 1.0.2"));
+ dnsdist::logging::getTopLogger("openssl-client-side")->info(Logr::Warning, "TLS hostname validation requested but not supported for OpenSSL < 1.0.2"));
#else /* DNSDIST */
warnlog("TLS hostname validation requested but not supported for OpenSSL < 1.0.2");
#endif /* DNSDIST */
return IOState::NeedWrite;
}
VERBOSESLOG(infolog("Warning, non-fatal error while writing to TLS connection: %s", gnutls_strerror(res)),
- dnsdist::logging::getTopLogger()->error(Logr::Info, gnutls_strerror(res), "Non-fatal error while writing to TLS connection", "tls.provider", Logging::Loggable("GnuTLS")));
+ dnsdist::logging::getTopLogger("gnutls")->error(Logr::Info, gnutls_strerror(res), "Non-fatal error while writing to TLS connection", "tls.provider", Logging::Loggable("GnuTLS")));
}
}
while (pos < toWrite);
return IOState::NeedRead;
}
VERBOSESLOG(infolog("Warning, non-fatal error while writing to TLS connection: %s", gnutls_strerror(res)),
- dnsdist::logging::getTopLogger()->error(Logr::Info, gnutls_strerror(res), "Non-fatal error while writing to TLS connection", "tls.provider", Logging::Loggable("GnuTLS")));
+ dnsdist::logging::getTopLogger("gnutls")->error(Logr::Info, gnutls_strerror(res), "Non-fatal error while writing to TLS connection", "tls.provider", Logging::Loggable("GnuTLS")));
}
}
while (pos < toRead);
}
else {
VERBOSESLOG(infolog("Non-fatal error while reading from TLS connection: %s", gnutls_strerror(res)),
- dnsdist::logging::getTopLogger()->error(Logr::Info, gnutls_strerror(res), "Non-fatal error while reading from TLS connection", "tls.provider", Logging::Loggable("GnuTLS")));
+ dnsdist::logging::getTopLogger("gnutls")->error(Logr::Info, gnutls_strerror(res), "Non-fatal error while reading from TLS connection", "tls.provider", Logging::Loggable("GnuTLS")));
}
}
}
else {
VERBOSESLOG(infolog("Non-fatal error while writing to TLS connection: %s", gnutls_strerror(res)),
- dnsdist::logging::getTopLogger()->error(Logr::Info, gnutls_strerror(res), "Non-fatal error while writing to TLS connection", "tls.provider", Logging::Loggable("GnuTLS")));
+ dnsdist::logging::getTopLogger("gnutls")->error(Logr::Info, gnutls_strerror(res), "Non-fatal error while writing to TLS connection", "tls.provider", Logging::Loggable("GnuTLS")));
}
}
}
if (rc != GNUTLS_E_SUCCESS) {
#if defined(DNSDIST)
SLOG(warnlog("Error loading OCSP response from file '%s' for certificate ('%s') and key ('%s') for TLS context on %s: %s", file, frontend.d_tlsConfig.d_certKeyPairs.at(count).d_cert, frontend.d_tlsConfig.d_certKeyPairs.at(count).d_key.value(), frontend.d_addr.toStringWithPort(), gnutls_strerror(rc)),
- dnsdist::logging::getTopLogger()->error(Logr::Warning, gnutls_strerror(rc), "Error loading OCSP response for TLS context", "tls.provider", Logging::Loggable("GnuTLS"), "frontend.address", Logging::Loggable(frontend.d_addr), "tls.ocsp_file", Logging::Loggable(file), "tls.certificate_file", Logging::Loggable(frontend.d_tlsConfig.d_certKeyPairs.at(count).d_cert), "tls.key_file", Logging::Loggable(frontend.d_tlsConfig.d_certKeyPairs.at(count).d_key.value())));
+ dnsdist::logging::getTopLogger("gnutls")->error(Logr::Warning, gnutls_strerror(rc), "Error loading OCSP response for TLS context", "tls.provider", Logging::Loggable("GnuTLS"), "frontend.address", Logging::Loggable(frontend.d_addr), "tls.ocsp_file", Logging::Loggable(file), "tls.certificate_file", Logging::Loggable(frontend.d_tlsConfig.d_certKeyPairs.at(count).d_cert), "tls.key_file", Logging::Loggable(frontend.d_tlsConfig.d_certKeyPairs.at(count).d_key.value())));
#else /* DNSDIST */
warnlog("Error loading OCSP response from file '%s' for certificate ('%s') and key ('%s') for TLS context on %s: %s", file, frontend.d_tlsConfig.d_certKeyPairs.at(count).d_cert, frontend.d_tlsConfig.d_certKeyPairs.at(count).d_key.value(), frontend.d_addr.toStringWithPort(), gnutls_strerror(rc));
#endif /* DNSDIST */
if (retval != 0) {
#ifdef DNSDIST
SLOG(warnlog("Could not set thread name %s for thread: %s", threadName, strerror(retval)),
- dnsdist::logging::getTopLogger()->withName("runtime")->error(Logr::Warning, retval, "Could not set thread name", "name", Logging::Loggable(threadName)));
+ dnsdist::logging::getTopLogger("runtime")->error(Logr::Warning, retval, "Could not set thread name", "name", Logging::Loggable(threadName)));
#else
SLOG(g_log<<Logger::Warning<<"Could not set thread name "<<threadName<<" for thread: "<<strerror(retval)<<endl,
g_slog->withName("runtime")->error(Logr::Warning, retval, "Could not set thread name", "name", Logging::Loggable(threadName)));