Added CLICON_LOG_DESTINATION and CLICON_LOG_FILE for al applications
This commit is contained in:
parent
26062d7003
commit
0234ed94bc
22 changed files with 498 additions and 163 deletions
|
|
@ -1168,6 +1168,7 @@ main(int argc,
|
|||
enum format_enum config_dump_format = FORMAT_XML;
|
||||
int print_version = 0;
|
||||
int stream_timeout = 0;
|
||||
int32_t d;
|
||||
|
||||
/* Create handle */
|
||||
if ((h = restconf_handle_init()) == NULL)
|
||||
|
|
@ -1187,17 +1188,13 @@ main(int argc,
|
|||
cligen_output(stdout, "Clixon version: %s\n", CLIXON_GITHASH);
|
||||
print_version++; /* plugins may also print versions w ca-version callback */
|
||||
break;
|
||||
case 'D' : { /* debug. Note this overrides any setting in the config */
|
||||
int d = 0;
|
||||
case 'D' : /* debug. Note this overrides any setting in the config */
|
||||
/* Try first symbolic, then numeric match */
|
||||
if ((d = clixon_debug_str2key(optarg)) < 0 &&
|
||||
sscanf(optarg, "%d", &d) != 1){
|
||||
usage(h, argv[0]);
|
||||
}
|
||||
dbg |= d;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'f': /* override config file */
|
||||
if (!strlen(optarg))
|
||||
|
|
@ -1210,13 +1207,18 @@ main(int argc,
|
|||
clicon_option_str_set(h, "CLICON_CONFIGDIR", optarg);
|
||||
break;
|
||||
case 'l': /* Log destination: s|e|o */
|
||||
if ((logdst = clixon_log_opt(optarg[0])) < 0)
|
||||
usage(h, argv0);
|
||||
if (logdst == CLIXON_LOG_FILE &&
|
||||
strlen(optarg)>1 &&
|
||||
clixon_log_file(optarg+1) < 0)
|
||||
goto done;
|
||||
break;
|
||||
if ((d = clixon_logdst_str2key(optarg)) < 0){
|
||||
if (optarg[0] == 'f'){ /* Check for special -lf<file> syntax */
|
||||
d = CLIXON_LOG_FILE;
|
||||
if (strlen(optarg) > 1 &&
|
||||
clixon_log_file(optarg+1) < 0)
|
||||
goto done;
|
||||
}
|
||||
else
|
||||
usage(h, argv[0]);
|
||||
}
|
||||
logdst = d;
|
||||
break;
|
||||
} /* switch getopt */
|
||||
|
||||
/*
|
||||
|
|
@ -1324,6 +1326,10 @@ main(int argc,
|
|||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
/* Read debug and log options from config file if not given by command-line */
|
||||
if (clixon_options_main_helper(h, dbg, logdst, __PROGRAM__) < 0)
|
||||
goto done;
|
||||
|
||||
/* Access the remaining argv/argc options (after --) w clicon-argv_get() */
|
||||
clicon_argv_set(h, argv0, argc, argv);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue