Each level includes itself plus the lower levels before it.
Not recommended to set this below 3.
+.. _setting-loglevel-show:
+
+``loglevel-show``
+-------------------
+
+- Bool
+- Default: no
+
+.. versionadded:: 4.9.0
+
+When enabled, log messages are formatted like structured logs, including their log level/priority: ``msg="Unable to launch, no backends configured for querying" prio="Error"``
+
.. _setting-lua-axfr-script:
``lua-axfr-script``
::arg().set("version-string", "PowerDNS version in packets - full, anonymous, powerdns or custom") = "full";
::arg().set("control-console", "Debugging switch - don't use") = "no"; // but I know you will!
::arg().set("loglevel", "Amount of logging. Higher is more. Do not set below 3") = "4";
+ ::arg().setSwitch("loglevel-show", "Include log level indicator in log output") = "no";
::arg().set("disable-syslog", "Disable logging to syslog, useful when running inside a supervisor that logs stdout") = "no";
::arg().set("log-timestamp", "Print timestamps in log lines") = "yes";
::arg().set("distributor-threads", "Default number of Distributor (backend) threads to start") = "3";
::arg().set("slave-cycle-interval") = ::arg()["xfr-cycle-interval"];
g_log.setLoglevel((Logger::Urgency)(::arg().asNum("loglevel")));
+ g_log.setPrefixed(::arg().mustDo("loglevel-show"));
g_log.disableSyslog(::arg().mustDo("disable-syslog"));
g_log.setTimestamps(::arg().mustDo("log-timestamp"));
g_log.toConsole((Logger::Urgency)(::arg().asNum("loglevel")));
#include "config.h"
#endif
+#include <iomanip>
#include <mutex>
#include "logger.hh"
}
}
- string prefix;
+ string severity;
if (d_prefixed) {
switch (u) {
case All:
- prefix = "[all] ";
+ severity = "All";
break;
case Alert:
- prefix = "[ALERT] ";
+ severity = "Alert";
break;
case Critical:
- prefix = "[CRITICAL] ";
+ severity = "Critical";
break;
case Error:
- prefix = "[ERROR] ";
+ severity = "Error";
break;
case Warning:
- prefix = "[WARNING] ";
+ severity = "Warning";
break;
case Notice:
- prefix = "[NOTICE] ";
+ severity = "Notice";
break;
case Info:
- prefix = "[INFO] ";
+ severity = "Info";
break;
case Debug:
- prefix = "[DEBUG] ";
+ severity = "Debug";
break;
case None:
- prefix = "[none] ";
+ severity = "None";
break;
}
}
static std::mutex m;
std::lock_guard<std::mutex> l(m); // the C++-2011 spec says we need this, and OSX actually does
- clog << string(buffer) + prefix + msg << endl;
+ if (d_prefixed) {
+ clog << string(static_cast<char*>(&buffer[0])) << "msg=" << std::quoted(msg) << " prio=" << std::quoted(severity) << endl;
+ }
+ else {
+ clog << string(static_cast<char*>(&buffer[0])) << msg << endl;
+ }
#ifndef RECURSOR
mustAccount = true;
#endif
bool opened;
bool d_disableSyslog;
bool d_timestamps{true};
- bool d_prefixed{false};
+ bool d_prefixed{false}; // this used to prefix the loglevel, but now causes formatting like structured logging
};
Logger& getLogger();