@item -d
When run in this mode, the program will not detach itself from the
terminal, and all messages will be sent to the terminal instead of to
-syslog.
+syslog. When @code{chronyd} was compiled with debugging support,
+this option can be used twice to print also debugging messages.
@item -f <conf-file>
This option can be used to specify an alternate location for the
configuration file (default @file{@SYSCONFDIR@/chrony.conf}).
.B \-d
When run in this mode, the program will not detach itself from the
terminal, and all messages will be sent to the terminal instead of
-to syslog.
+to syslog. When \fBchronyd\fR was compiled with debugging support,
+this option can be used twice to print also debugging messages.
.TP
\fB\-f\fR \fIconf-file\fR
This option can be used to specify an alternate location for the
--disable-forcednsretry Don't retry on permanent DNS error
--with-sendmail=PATH Path to sendmail binary [/usr/lib/sendmail]
--enable-trace Enable tracing
+ --enable-debug Enable debugging support
Fine tuning of the installation directories:
--sysconfdir=DIR chrony.conf location [/etc]
EXTRA_DEFS=""
SYSDEFS=""
-# Support for readline (on by default)
+debug=0
feat_readline=1
try_readline=1
try_editline=1
--enable-trace )
add_def TRACEON
;;
+ --enable-debug )
+ debug=1
+ ;;
--disable-readline )
feat_readline=0
;;
CHRONYVARDIR=$SETCHRONYVARDIR
fi
+add_def DEBUG $debug
add_def DEFAULT_CONF_FILE "\"$SYSCONFDIR/chrony.conf\""
add_def MAIL_PROGRAM "\"$mail_program\""
static int parent_fd = 0;
+static int log_debug = 0;
+
static time_t last_limited = 0;
#ifdef WINNT
if (system_log) {
int priority;
switch (severity) {
+ case LOGS_DEBUG:
+ priority = LOG_DEBUG;
+ break;
case LOGS_INFO:
priority = LOG_INFO;
break;
time_t t;
struct tm stm;
+ /* Don't write debug messages if not enabled */
+ if (!log_debug && severity == LOGS_DEBUG)
+ return;
+
#ifdef WINNT
#else
if (!system_log) {
va_end(other_args);
switch (severity) {
+ case LOGS_DEBUG:
case LOGS_INFO:
case LOGS_WARN:
case LOGS_ERR:
/* ================================================== */
+void LOG_EnableDebug(void)
+{
+ log_debug = 1;
+}
+
+/* ================================================== */
+
void
LOG_SetParentFd(int fd)
{
#define FORMAT_ATTRIBUTE_PRINTF(str, first)
#endif
+#define DEBUG_LOG(facility, ...) \
+ do { \
+ if (DEBUG) \
+ LOG_Message(LOGS_DEBUG, facility, __LINE__, __FILE__, FUNCTION_NAME, __VA_ARGS__); \
+ } while (0)
#define LOG(severity, facility, ...) LOG_Message(severity, facility, __LINE__, __FILE__, FUNCTION_NAME, __VA_ARGS__)
#define LOG_FATAL(facility, ...) LOG_Message(LOGS_FATAL, facility, __LINE__, __FILE__, FUNCTION_NAME, __VA_ARGS__)
LOGS_INFO,
LOGS_WARN,
LOGS_ERR,
- LOGS_FATAL
+ LOGS_FATAL,
+ LOGS_DEBUG
} LOG_Severity;
/* Definition of facility. Each message is tagged with who generated
int line_number, const char *filename,
const char *function_name, const char *format, ...);
+/* Enable logging of debug messages */
+extern void LOG_EnableDebug(void);
+
/* Log messages to syslog instead of stderr */
extern void LOG_OpenSystemLog(void);
} else if (!strcmp("-n", *argv)) {
nofork = 1;
} else if (!strcmp("-d", *argv)) {
- debug = 1;
+ debug++;
nofork = 1;
} else if (!strcmp("-4", *argv)) {
address_family = IPADDR_INET4;
LOG_OpenSystemLog();
}
+ if (debug > 1) {
+ LOG_EnableDebug();
+ }
+
LOG(LOGS_INFO, LOGF_Main, "chronyd version %s starting", CHRONY_VERSION);
DNS_SetAddressFamily(address_family);