#include "lua-recursor4.hh"
#include <fstream>
#include "logger.hh"
+#include "logging.hh"
#include "dnsparser.hh"
#include "syncres.hh"
#include "namespaces.hh"
}
}
catch(std::exception& e) {
- g_log <<Logger::Error<<e.what()<<endl;
+ SLOG(g_log <<Logger::Error<<e.what()<<endl,
+ g_slog->withName("lua")->error(Logr::Error, e.what(), "Error in call to DNSSuffixMatchGroup:add"));
}
}
);
static void warnDrop(const RecursorLua4::DNSQuestion& dq)
{
if (dq.rcode == -2) {
- g_log << Logger::Error << "Returning -2 (pdns.DROP) is not supported anymore, see https://docs.powerdns.com/recursor/lua-scripting/hooks.html#hooksemantics" << endl;
+ SLOG(g_log << Logger::Error << "Returning -2 (pdns.DROP) is not supported anymore, see https://docs.powerdns.com/recursor/lua-scripting/hooks.html#hooksemantics" << endl,
+ g_slog->withName("lua")->info(Logr::Error,"Returning -2 (pdns.DROP) is not supported anymore, see https://docs.powerdns.com/recursor/lua-scripting/hooks.html#hooksemantics"));
// We *could* set policy here, but that would also mean interfering with rcode and the return code of the hook.
// So leave it at the error message.
}
dq.udpAnswer = std::string(reinterpret_cast<const char*>(p.data()), p.size());
auto cbFunc = d_lw->readVariable<boost::optional<luacall_t>>(dq.udpCallback).get_value_or(0);
if (!cbFunc) {
- g_log << Logger::Error << "Attempted callback for Lua UDP Query/Response which could not be found" << endl;
+ SLOG(g_log << Logger::Error << "Attempted callback for Lua UDP Query/Response which could not be found" << endl,
+ g_slog->withName("lua")->info(Logr::Error, "Attempted callback for Lua UDP Query/Response which could not be found"));
return false;
}
bool result = cbFunc(&dq);
}
catch (const std::exception& e) {
SLOG(g_log << Logger::Error << "STL error " << makeLoginfo(comboWriter) << ": " << e.what(),
- resolver.d_slog->error(Logr::Error, e.what(), "Exception in resolver context ", "exception", Logging::Loggable("std::exception")));
+ resolver.d_slog->error(Logr::Error, e.what(), "Exception in resolver context", "exception", Logging::Loggable("std::exception")));
// Luawrapper nests the exception from Lua, so we unnest it here
try {
#endif
if (address.sin6.sin6_family == AF_INET6 && setsockopt(socketFd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one)) < 0) {
int err = errno;
- SLOG(g_log << Logger::Error << "Failed to set IPv6 socket to IPv6 only, continuing anyhow: " << stringerror(err) << endl,
- log->error(Logr::Error, "Failed to set IPv6 socket to IPv6 only, continuing anyhow"));
+ SLOG(g_log << Logger::Warning << "Failed to set IPv6 socket to IPv6 only, continuing anyhow: " << stringerror(err) << endl,
+ log->error(Logr::Warning, "Failed to set IPv6 socket to IPv6 only, continuing anyhow"));
}
}
if (::arg().mustDo("non-local-bind")) {
{
if (!RecThreadInfo::self().isDistributor()) {
SLOG(g_log << Logger::Error << "distributeAsyncFunction() has been called by a worker (" << RecThreadInfo::id() << ")" << endl,
- g_slog->info(Logr::Error, "distributeAsyncFunction() has been called by a worker")); // tid will be added
+ g_slog->withName("runtime")->info(Logr::Error, "distributeAsyncFunction() has been called by a worker")); // tid will be added
_exit(1);
}
}
catch (const std::exception& e) {
SLOG(g_log << Logger::Warning << "Error while loading the Public Suffix List from '" << file << "', falling back to the built-in list: " << e.what() << endl,
- g_slog->withName("runtime")->error(Logr::Error, e.what(), "Loaded the Public Suffix List", "file", Logging::Loggable(file)));
+ g_slog->withName("runtime")->error(Logr::Error, e.what(), "Error while loading the Public Suffix List", "file", Logging::Loggable(file)));
}
}
}
catch (const std::exception& e) {
SLOG(g_log << Logger::Error << "Problem configuring 'rpzPrimary': " << e.what() << endl,
- lci.d_slog->error(Logr::Critical, e.what(), "Exception configuring 'rpzPrimary'", "exception", Logging::Loggable("std::exception")));
- exit(1); // FIXME proper exit code?
+ lci.d_slog->error(Logr::Error, e.what(), "Exception configuring 'rpzPrimary'", "exception", Logging::Loggable("std::exception")));
}
catch (const PDNSException& e) {
SLOG(g_log << Logger::Error << "Problem configuring 'rpzPrimary': " << e.reason << endl,
- lci.d_slog->error(Logr::Critical, e.reason, "Exception configuring 'rpzPrimary'", Logging::Loggable("PDNSException")));
- exit(1); // FIXME proper exit code?
+ lci.d_slog->error(Logr::Error, e.reason, "Exception configuring 'rpzPrimary'", Logging::Loggable("PDNSException")));
}
delayedThreads.rpzPrimaryThreads.emplace_back(primaries, defpol, defpolOverrideLocal, maxTTL, zoneIdx, tt, maxReceivedXFRMBytes, localAddress, axfrTimeout, refresh, sr, dumpFile);
log->info(Logr::Debug, "done", "rcode", Logging::Loggable(res), "records", Logging::Loggable(ret.size()));
}
catch (const std::exception& e) {
- log->error(Logr::Error, msg, e.what());
+ log->error(Logr::Warning, msg, e.what());
}
catch (const PDNSException& e) {
- log->error(Logr::Error, msg, e.reason);
+ log->error(Logr::Warning, msg, e.reason);
}
catch (const ImmediateServFailException& e) {
if (logErrors) {
- log->error(Logr::Error, msg, e.reason);
+ log->error(Logr::Warning, msg, e.reason);
}
}
catch (const PolicyHitException& e) {
if (logErrors) {
- log->error(Logr::Notice, msg, "PolicyHit");
+ log->error(Logr::Warning, msg, "PolicyHit");
}
}
catch (...) {
- log->error(Logr::Error, msg, "Unexpectec exception");
+ log->error(Logr::Warning, msg, "Unexpectec exception");
}
if (exceptionOccurred) {
if (task.d_refreshMode) {
log->info(Logr::Debug, "done", "ok", Logging::Loggable(tryOK));
}
catch (const std::exception& e) {
- log->error(Logr::Error, msg, e.what());
+ log->error(Logr::Warning, msg, e.what());
}
catch (const PDNSException& e) {
- log->error(Logr::Error, msg, e.reason);
+ log->error(Logr::Warning, msg, e.reason);
}
catch (const ImmediateServFailException& e) {
if (logErrors) {
- log->error(Logr::Error, msg, e.reason);
+ log->error(Logr::Warning, msg, e.reason);
}
}
catch (const PolicyHitException& e) {
}
}
catch (...) {
- log->error(Logr::Error, msg, "Unexpected exception");
+ log->error(Logr::Warning, msg, "Unexpected exception");
}
if (exceptionOccurred) {
++s_resolve_tasks.exceptions;
if (address.sin6.sin6_family == AF_INET6 && setsockopt(socketFd, IPPROTO_IPV6, IPV6_V6ONLY, &tmp, sizeof(tmp)) < 0) {
int err = errno;
SLOG(g_log << Logger::Error << "Failed to set IPv6 socket to IPv6 only, continuing anyhow: " << stringerror(err) << endl,
- log->error(Logr::Error, err, "Failed to set IPv6 socket to IPv6 only, continuing anyhow"));
+ log->error(Logr::Warning, err, "Failed to set IPv6 socket to IPv6 only, continuing anyhow"));
}
#ifdef TCP_DEFER_ACCEPT
res = sr.beginResolve(qname, qtype, qclass, ret, 0);
}
catch (const PDNSException& e) {
- SLOG(g_log << Logger::Error << "Failed to resolve " << qname << ", got pdns exception: " << e.reason << endl,
- log->error(Logr::Error, e.reason, msg, "exception", Logging::Loggable("PDNSException")));
+ SLOG(g_log << Logger::Warning << "Failed to resolve " << qname << ", got pdns exception: " << e.reason << endl,
+ log->error(Logr::Warning, e.reason, msg, "exception", Logging::Loggable("PDNSException")));
ret.clear();
}
catch (const ImmediateServFailException& e) {
- SLOG(g_log << Logger::Error << "Failed to resolve " << qname << ", got ImmediateServFailException: " << e.reason << endl,
- log->error(Logr::Error, e.reason, msg, "exception", Logging::Loggable("ImmediateServFailException")));
+ SLOG(g_log << Logger::Warning << "Failed to resolve " << qname << ", got ImmediateServFailException: " << e.reason << endl,
+ log->error(Logr::Warning, e.reason, msg, "exception", Logging::Loggable("ImmediateServFailException")));
ret.clear();
}
catch (const PolicyHitException& e) {
- SLOG(g_log << Logger::Error << "Failed to resolve " << qname << ", got a policy hit" << endl,
- log->info(Logr::Error, msg, "exception", Logging::Loggable("PolicyHitException")));
+ SLOG(g_log << Logger::Warning << "Failed to resolve " << qname << ", got a policy hit" << endl,
+ log->info(Logr::Warning, msg, "exception", Logging::Loggable("PolicyHitException")));
ret.clear();
}
catch (const std::exception& e) {
- SLOG(g_log << Logger::Error << "Failed to resolve " << qname << ", got STL error: " << e.what() << endl,
- log->error(Logr::Error, e.what(), msg, "exception", Logging::Loggable("std::exception")));
+ SLOG(g_log << Logger::Warning << "Failed to resolve " << qname << ", got STL error: " << e.what() << endl,
+ log->error(Logr::Warning, e.what(), msg, "exception", Logging::Loggable("std::exception")));
ret.clear();
}
catch (...) {
- SLOG(g_log << Logger::Error << "Failed to resolve " << qname << ", got an exception" << endl,
- log->info(Logr::Error, msg));
+ SLOG(g_log << Logger::Warning << "Failed to resolve " << qname << ", got an exception" << endl,
+ log->info(Logr::Warning, msg));
ret.clear();
}
if (initgroups(pw->pw_name, gid)<0) {
int err = errno;
SLOG(g_log<<Logger::Critical<<"Unable to set supplementary groups: "<<stringerror(err)<<endl,
- g_slog->withName("runtime")->error(Logr::Critical, err, "Unable to drop supplementary groups"));
+ g_slog->withName("runtime")->error(Logr::Critical, err, "Unable to set supplementary groups"));
exit(1);
}
}
if(setuid(uid)<0) {
int err = errno;
SLOG(g_log<<Logger::Critical<<"Unable to set effective user id to "<<uid<<": "<<stringerror(err)<<endl,
- g_slog->withName("runtime")->error(Logr::Error, err, "Unable to set effective user id", "uid", Logging::Loggable(uid)));
+ g_slog->withName("runtime")->error(Logr::Critical, err, "Unable to set effective user id", "uid", Logging::Loggable(uid)));
exit(1);
}
else {