Add logbanner directive
This commit is contained in:
parent
7a6ee1d729
commit
7ab2c0e4a5
4 changed files with 36 additions and 1 deletions
11
chrony.texi
11
chrony.texi
|
@ -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
|
||||
|
|
21
conf.c
21
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)
|
||||
{
|
||||
|
|
1
conf.h
1
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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue