]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Add logbanner directive
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 13 Oct 2010 15:50:22 +0000 (17:50 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 13 Oct 2010 15:50:22 +0000 (17:50 +0200)
chrony.texi
conf.c
conf.h
logging.c

index f86a0ac0bb9579a67726831e7fa5c498f08afb22..26320ceeb46212fe5a9d5b01ad16b6017e0d2f6b 100644 (file)
@@ -1185,6 +1185,7 @@ directives can occur in any order in the file.
 * linux_freq_scale directive::  Define a non-standard value to compensate the kernel frequency bias
 * local directive::             Allow unsynchronised machine to act as server
 * log directive::               Make daemon log certain sets of information
+* logbanner directive::         Specify how often is banner written to log files
 * logchange directive::         Generate syslog messages if large offsets occur
 * logdir directive::            Specify directory for logging
 * mailonchange directive::      Send email if a clock correction above a threshold occurs
@@ -2108,6 +2109,16 @@ A banner is periodically written to the log file to indicate the
 meanings of the columns.
 @c }}}
 @c }}}
+@c {{{ logbanner
+@node logbanner directive
+@subsection logbanner
+A banner is periodically written to the log files enabled by the
+@code{log} directive to indicate the meanings of the columns.
+
+The @code{logbanner} directive specifies after how many entries in the
+log file should be the banner written. The default is 32, and 0 can be
+used to disable it entirely.
+@c }}}
 @c {{{ logchange
 @node logchange directive
 @subsection logchange
diff --git a/conf.c b/conf.c
index 5bfd3264f7eb164bf87ff5fc264a7a65710421d5..e4ed75a894b44df9be888c20810feaeb88b7d8bd 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -74,6 +74,7 @@ static void parse_dumponexit(const char *);
 static void parse_keyfile(const char *);
 static void parse_rtcfile(const char *);
 static void parse_log(const char *);
+static void parse_logbanner(const char *);
 static void parse_logdir(const char *);
 static void parse_maxupdateskew(const char *);
 static void parse_peer(const char *);
@@ -129,6 +130,7 @@ static int do_log_rtc = 0;
 static int do_log_refclocks = 0;
 static int do_log_tempcomp = 0;
 static int do_dump_on_exit = 0;
+static int log_banner = 32;
 static char *logdir = ".";
 static char *dumpdir = ".";
 
@@ -224,6 +226,7 @@ static const Command commands[] = {
   {"driftfile", 9, parse_driftfile},
   {"keyfile", 7, parse_keyfile},
   {"rtcfile", 7, parse_rtcfile},
+  {"logbanner", 9, parse_logbanner},
   {"logdir", 6, parse_logdir},
   {"log", 3, parse_log},
   {"dumponexit", 10, parse_dumponexit},
@@ -645,6 +648,16 @@ parse_rtcdevice(const char *line)
 
 /* ================================================== */
 
+static void
+parse_logbanner(const char *line)
+{
+  if (sscanf(line, "%d", &log_banner) != 1) {
+    LOG(LOGS_WARN, LOGF_Configure, "Could not read logbanner number at line %d in file", line_number);
+  }
+}
+
+/* ================================================== */
+
 static void
 parse_logdir(const char *line)
 {
@@ -1274,6 +1287,14 @@ CNF_GetDriftFile(void)
 
 /* ================================================== */
 
+int
+CNF_GetLogBanner(void)
+{
+  return log_banner;
+}
+
+/* ================================================== */
+
 char *
 CNF_GetLogDir(void)
 {
diff --git a/conf.h b/conf.h
index cf8788b42d640be074af9699ca1ea0eba3c116af..9ccef777e4672f2c9ef7b74087e54c9897b2c394 100644 (file)
--- a/conf.h
+++ b/conf.h
@@ -48,6 +48,7 @@ extern unsigned short CNF_GetNTPPort(void);
 extern char *CNF_GetDriftFile(void);
 extern char *CNF_GetLogDir(void);
 extern char *CNF_GetDumpDir(void);
+extern int CNF_GetLogBanner(void);
 extern int CNF_GetLogMeasurements(void);
 extern int CNF_GetLogStatistics(void);
 extern int CNF_GetLogTracking(void);
index 61cb973200d7ed653411c76862bfad1b86cb097a..591b552554ae03d2b96324fb91f4f9cc15914b94 100644 (file)
--- a/logging.c
+++ b/logging.c
@@ -233,6 +233,7 @@ void
 LOG_FileWrite(LOG_FileID id, const char *format, ...)
 {
   va_list other_args;
+  int banner;
 
   if (id < 0 || id >= n_filelogs || !logfiles[id].name)
     return;
@@ -249,7 +250,8 @@ LOG_FileWrite(LOG_FileID id, const char *format, ...)
     }
   }
 
-  if (logfiles[id].writes++ % 32 == 0) {
+  banner = CNF_GetLogBanner();
+  if (banner && logfiles[id].writes++ % banner == 0) {
     char bannerline[256];
     int i, bannerlen;