int g_argc;
char** g_argv;
static string s_structured_logger_backend;
+static Logger::Urgency s_logUrgency;
/* without reuseport, all listeners share the same sockets */
deferredAdd_t g_deferredAdds;
#ifdef HAVE_SYSTEMD
static void loggerSDBackend(const Logging::Entry& entry)
{
+ Logger::Urgency u = entry.d_priority ? Logger::Urgency(entry.d_priority) : Logger::Info;
+ if (u > s_logUrgency) {
+ return;
+ }
// We need to keep the string in mem until sd_journal_sendv has ben called
vector<string> strings;
auto appendKeyAndVal = [&strings](const string& k, const string& v) {
{
static thread_local std::stringstream buf;
+ Logger::Urgency u = entry.d_priority ? Logger::Urgency(entry.d_priority) : Logger::Info;
+ if (u > s_logUrgency) {
+ return;
+ }
buf.str("");
buf << "msg=" << std::quoted(entry.message);
if (entry.error) {
buf << " ";
buf << v.first << "=" << std::quoted(v.second);
}
- Logger::Urgency u = entry.d_priority ? Logger::Urgency(entry.d_priority) : Logger::Info;
+
g_log << u << buf.str() << endl;
}
// Pick up options given on command line to setup logging asap.
g_quiet = ::arg().mustDo("quiet");
- Logger::Urgency logUrgency = (Logger::Urgency)::arg().asNum("loglevel");
+ s_logUrgency = (Logger::Urgency)::arg().asNum("loglevel");
g_slogStructured = ::arg().mustDo("structured-logging");
s_structured_logger_backend = ::arg()["structured-logging-backend"];
- if (logUrgency < Logger::Error)
- logUrgency = Logger::Error;
- if (!g_quiet && logUrgency < Logger::Info) { // Logger::Info=6, Logger::Debug=7
- logUrgency = Logger::Info; // if you do --quiet=no, you need Info to also see the query log
+ if (s_logUrgency < Logger::Error)
+ s_logUrgency = Logger::Error;
+ if (!g_quiet && s_logUrgency < Logger::Info) { // Logger::Info=6, Logger::Debug=7
+ s_logUrgency = Logger::Info; // if you do --quiet=no, you need Info to also see the query log
}
- g_log.setLoglevel(logUrgency);
- g_log.toConsole(logUrgency);
+ g_log.setLoglevel(s_logUrgency);
+ g_log.toConsole(s_logUrgency);
string configname = ::arg()["config-dir"] + "/recursor.conf";
if (::arg()["config-name"] != "") {
::arg().parse(argc, argv);
g_quiet = ::arg().mustDo("quiet");
- logUrgency = (Logger::Urgency)::arg().asNum("loglevel");
+ s_logUrgency = (Logger::Urgency)::arg().asNum("loglevel");
g_slogStructured = ::arg().mustDo("structured-logging");
- if (logUrgency < Logger::Error)
- logUrgency = Logger::Error;
- if (!g_quiet && logUrgency < Logger::Info) { // Logger::Info=6, Logger::Debug=7
- logUrgency = Logger::Info; // if you do --quiet=no, you need Info to also see the query log
+ if (s_logUrgency < Logger::Error)
+ s_logUrgency = Logger::Error;
+ if (!g_quiet && s_logUrgency < Logger::Info) { // Logger::Info=6, Logger::Debug=7
+ s_logUrgency = Logger::Info; // if you do --quiet=no, you need Info to also see the query log
}
- g_log.setLoglevel(logUrgency);
- g_log.toConsole(logUrgency);
+ g_log.setLoglevel(s_logUrgency);
+ g_log.toConsole(s_logUrgency);
if (!::arg()["chroot"].empty() && !::arg()["api-config-dir"].empty()) {
SLOG(g_log << Logger::Error << "Using chroot and enabling the API is not possible" << endl,