config: convert 'logging_level' to the new scheme.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2015-08-13 22:25:39 +02:00
parent e8a2956ce0
commit caaf72c5ec
3 changed files with 5 additions and 16 deletions

View File

@ -94,6 +94,7 @@ struct config_item config_tab[] = {
GLOB_ITEM_INT("assume_two_step", 0, 0, 1),
GLOB_ITEM_INT("check_fup_sync", 0, 0, 1),
GLOB_ITEM_DBL("first_step_threshold", 0.00002, 0.0, DBL_MAX),
GLOB_ITEM_INT("logging_level", LOG_INFO, PRINT_LEVEL_MIN, PRINT_LEVEL_MAX),
GLOB_ITEM_INT("max_frequency", 900000000, 0, INT_MAX),
GLOB_ITEM_DBL("step_threshold", 0.0, 0.0, DBL_MAX),
GLOB_ITEM_INT("tx_timestamp_timeout", 1, 1, INT_MAX),
@ -623,15 +624,6 @@ static enum parser_result parse_global_setting(const char *option,
return OUT_OF_RANGE;
strncpy(cfg->uds_address, value, MAX_IFNAME_SIZE);
} else if (!strcmp(option, "logging_level")) {
r = get_ranged_int(value, &val,
PRINT_LEVEL_MIN, PRINT_LEVEL_MAX);
if (r != PARSED_OK)
return r;
if (!(cfg_ignore & CFG_IGNORE_PRINT_LEVEL)) {
cfg->print_level = val;
}
} else if (!strcmp(option, "verbose")) {
r = get_ranged_int(value, &val, 0, 1);
if (r != PARSED_OK)

View File

@ -49,7 +49,6 @@ struct interface {
#define CFG_IGNORE_TRANSPORT (1 << 1)
#define CFG_IGNORE_TIMESTAMPING (1 << 2)
#define CFG_IGNORE_SLAVEONLY (1 << 3)
#define CFG_IGNORE_PRINT_LEVEL (1 << 4)
#define CFG_IGNORE_USE_SYSLOG (1 << 5)
#define CFG_IGNORE_VERBOSE (1 << 6)
@ -87,7 +86,6 @@ struct config {
unsigned char *udp6_scope;
char *uds_address;
int print_level;
int use_syslog;
int verbose;
};

View File

@ -118,7 +118,6 @@ static struct config cfg_settings = {
.udp6_scope = &udp6_scope,
.uds_address = uds_path,
.print_level = LOG_INFO,
.use_syslog = 1,
.verbose = 0,
@ -169,7 +168,7 @@ int main(int argc, char *argv[])
struct clock *clock;
struct config *cfg = &cfg_settings;
struct defaultDS *ds = &cfg_settings.dds.dds;
int phc_index = -1, required_modes = 0;
int phc_index = -1, print_level, required_modes = 0;
if (handle_term_signals())
return -1;
@ -240,10 +239,10 @@ int main(int argc, char *argv[])
*cfg_ignore |= CFG_IGNORE_SLAVEONLY;
break;
case 'l':
if (get_arg_val_i(c, optarg, &cfg_settings.print_level,
if (get_arg_val_i(c, optarg, &print_level,
PRINT_LEVEL_MIN, PRINT_LEVEL_MAX))
return -1;
*cfg_ignore |= CFG_IGNORE_PRINT_LEVEL;
config_set_int(cfg, "logging_level", print_level);
break;
case 'm':
cfg_settings.verbose = 1;
@ -294,7 +293,7 @@ int main(int argc, char *argv[])
print_set_progname(progname);
print_set_verbose(cfg_settings.verbose);
print_set_syslog(cfg_settings.use_syslog);
print_set_level(cfg_settings.print_level);
print_set_level(config_get_int(cfg, NULL, "logging_level"));
if (STAILQ_EMPTY(&cfg_settings.interfaces)) {
fprintf(stderr, "no interface specified\n");