uint16_t g_maxOutstanding{std::numeric_limits<uint16_t>::max()};
uint32_t g_staleCacheEntriesTTL{0};
bool g_syslog{true};
+bool g_logtimestamps{false};
bool g_allowEmptyResponse{false};
GlobalStateHolder<NetmaskGroup> g_ACL;
cout<<" (use with e.g. systemd and daemontools)\n";
cout<<"--disable-syslog Don't log to syslog, only to stdout\n";
cout<<" (use with e.g. systemd)\n";
+ cout<<"--log-timestamps Prepend timestamps to messages logged to stdout.\n";
cout<<"-u,--uid uid Change the process user ID after binding sockets\n";
cout<<"-v,--verbose Enable verbose mode\n";
cout<<"-V,--version Show dnsdist version information and exit\n";
{"gid", required_argument, 0, 'g'},
{"help", no_argument, 0, 'h'},
{"local", required_argument, 0, 'l'},
+ {"log-timestamps", no_argument, 0, 4},
{"setkey", required_argument, 0, 'k'},
{"supervised", no_argument, 0, 3},
{"uid", required_argument, 0, 'u'},
case 3:
g_cmdLine.beSupervised=true;
break;
+ case 4:
+ g_logtimestamps=true;
+ break;
case 'C':
g_cmdLine.config=optarg;
break;
daemontools).
--disable-syslog Disable logging to syslog. Use this when running inside a supervisor
that handles logging (like systemd).
+--log-timestamps Prepend timestamps to messages logged to standard out.
-u, --uid <uid> Change the process user to *uid* after binding sockets. *uid* can be
a name or number.
-g, --gid <gid> Change the process group to *gid* after binding sockets. *gid* Can
#pragma once
#include <iostream>
#include <sstream>
+#include "config.h"
#if !defined(RECURSOR)
#include <syslog.h>
#else
extern bool g_verbose;
extern bool g_syslog;
+#ifdef DNSDIST
+extern bool g_logtimestamps;
+#endif
inline void setSyslogFacility(int facility)
{
{
std::ostringstream str;
dolog(str, s, args...);
+
if(g_syslog)
syslog(level, "%s", str.str().c_str());
+
+#ifdef DNSDIST
+ if (g_logtimestamps) {
+ char buffer[50] = "";
+ struct tm tm;
+ time_t t;
+ time(&t);
+ localtime_r(&t, &tm);
+ strftime(buffer, sizeof(buffer), "%b %d %H:%M:%S ", &tm);
+ std::cout<<buffer;
+ }
+#endif
+
std::cout<<str.str()<<std::endl;
}