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
|
|
@ -359,6 +359,7 @@ main(int argc,
|
|||
int config_dump = 0;
|
||||
enum format_enum config_dump_format = FORMAT_XML;
|
||||
int print_version = 0;
|
||||
int32_t d;
|
||||
|
||||
/* Create handle */
|
||||
if ((h = clixon_handle_init()) == NULL)
|
||||
|
|
@ -386,7 +387,7 @@ main(int argc,
|
|||
print_version++; /* plugins may also print versions w ca-version callback */
|
||||
break;
|
||||
case 'D' : { /* debug */
|
||||
int d = 0;
|
||||
int32_t d = 0;
|
||||
/* Try first symbolic, then numeric match */
|
||||
if ((d = clixon_debug_str2key(optarg)) < 0 &&
|
||||
sscanf(optarg, "%d", &d) != 1){
|
||||
|
|
@ -400,13 +401,18 @@ main(int argc,
|
|||
usage(h, argv[0]);
|
||||
clicon_option_str_set(h, "CLICON_CONFIGFILE", optarg);
|
||||
break;
|
||||
case 'l': /* Log destination: s|e|o */
|
||||
if ((logdst = clixon_log_opt(optarg[0])) < 0)
|
||||
usage(h, argv[0]);
|
||||
if (logdst == CLIXON_LOG_FILE &&
|
||||
strlen(optarg)>1 &&
|
||||
clixon_log_file(optarg+1) < 0)
|
||||
goto done;
|
||||
case 'l': /* Log destination: s|e|o */
|
||||
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;
|
||||
}
|
||||
if (print_version)
|
||||
|
|
@ -467,6 +473,9 @@ 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