main: add option to specify minimum log severity level
The -L option can be used to disable logging of less severe messages, e.g informational or warnings.
This commit is contained in:
parent
1227873b88
commit
70fa3a6905
2 changed files with 12 additions and 3 deletions
|
@ -70,6 +70,12 @@ print also debugging messages.
|
||||||
This option specifies a file which should be used for logging instead of syslog
|
This option specifies a file which should be used for logging instead of syslog
|
||||||
or terminal.
|
or terminal.
|
||||||
|
|
||||||
|
*-L* _level_::
|
||||||
|
This option specifies the minimum severity level of messages to be written to
|
||||||
|
the log file, syslog, or terminal. The following levels can be specified:
|
||||||
|
0 (informational), 1 (warning), 2 (non-fatal error), and 3 (fatal error). The
|
||||||
|
default value is 0.
|
||||||
|
|
||||||
*-q*::
|
*-q*::
|
||||||
When run in this mode, *chronyd* will set the system clock once and exit. It
|
When run in this mode, *chronyd* will set the system clock once and exit. It
|
||||||
will not detach from the terminal.
|
will not detach from the terminal.
|
||||||
|
|
9
main.c
9
main.c
|
@ -406,7 +406,7 @@ int main
|
||||||
int opt, debug = 0, nofork = 0, address_family = IPADDR_UNSPEC;
|
int opt, debug = 0, nofork = 0, address_family = IPADDR_UNSPEC;
|
||||||
int do_init_rtc = 0, restarted = 0, client_only = 0, timeout = 0;
|
int do_init_rtc = 0, restarted = 0, client_only = 0, timeout = 0;
|
||||||
int scfilter_level = 0, lock_memory = 0, sched_priority = 0;
|
int scfilter_level = 0, lock_memory = 0, sched_priority = 0;
|
||||||
int clock_control = 1, system_log = 1;
|
int clock_control = 1, system_log = 1, log_severity = LOGS_INFO;
|
||||||
int config_args = 0;
|
int config_args = 0;
|
||||||
|
|
||||||
do_platform_checks();
|
do_platform_checks();
|
||||||
|
@ -427,7 +427,7 @@ int main
|
||||||
optind = 1;
|
optind = 1;
|
||||||
|
|
||||||
/* Parse short command-line options */
|
/* Parse short command-line options */
|
||||||
while ((opt = getopt(argc, argv, "46df:F:hl:mnP:qQrRst:u:vx")) != -1) {
|
while ((opt = getopt(argc, argv, "46df:F:hl:L:mnP:qQrRst:u:vx")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case '4':
|
case '4':
|
||||||
case '6':
|
case '6':
|
||||||
|
@ -447,6 +447,9 @@ int main
|
||||||
case 'l':
|
case 'l':
|
||||||
log_file = optarg;
|
log_file = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'L':
|
||||||
|
log_severity = parse_int_arg(optarg);
|
||||||
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
lock_memory = 1;
|
lock_memory = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -510,7 +513,7 @@ int main
|
||||||
LOG_OpenSystemLog();
|
LOG_OpenSystemLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_SetMinSeverity(debug >= 2 ? LOGS_DEBUG : LOGS_INFO);
|
LOG_SetMinSeverity(debug >= 2 ? LOGS_DEBUG : log_severity);
|
||||||
|
|
||||||
LOG(LOGS_INFO, "chronyd version %s starting (%s)", CHRONY_VERSION, CHRONYD_FEATURES);
|
LOG(LOGS_INFO, "chronyd version %s starting (%s)", CHRONY_VERSION, CHRONYD_FEATURES);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue