Added file logging (-l f or -l f<file>) for cases where neither syslog nor stderr is useful\
.
This commit is contained in:
parent
ef9bb742d1
commit
c53f3f2fe3
5 changed files with 24 additions and 16 deletions
|
|
@ -5,12 +5,12 @@
|
||||||
### Major New features
|
### Major New features
|
||||||
|
|
||||||
### API changes on existing features (you may need to change your code)
|
### API changes on existing features (you may need to change your code)
|
||||||
* clixon_netconf -S is obsolete. Use clixon_netconf -l s instead.
|
* Application command option -S to clixon_netconf is obsolete. Use `clixon_netconf -l s` instead.
|
||||||
|
|
||||||
### Minor changes
|
### Minor changes
|
||||||
* Unified log handling for all clicon applications using -l e|o|s|f.
|
* Unified log handling for all clicon applications using -l e|o|s|f<file>.
|
||||||
* The options stand for e:stderr, o:stdout, s: syslog, f:file
|
* The options stand for e:stderr, o:stdout, s: syslog, f:file
|
||||||
* Added file logging (-l f)for cases where neither syslog nor stderr is useful.
|
* Added file logging (`-l f` or `-l f<file>`) for cases where neither syslog nor stderr is useful.
|
||||||
* Obsoleted COMPAT_CLIV and COMPAT_XSL that were optional in 3.7
|
* Obsoleted COMPAT_CLIV and COMPAT_XSL that were optional in 3.7
|
||||||
* Added -l option for clixon_backend for directing syslog to stderr or stdout if running in foreground
|
* Added -l option for clixon_backend for directing syslog to stderr or stdout if running in foreground
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ usage(clicon_handle h,
|
||||||
" -s <mode>\tSpecify backend startup mode: none|startup|running|init (replaces -IRCr\n"
|
" -s <mode>\tSpecify backend startup mode: none|startup|running|init (replaces -IRCr\n"
|
||||||
" -c <file>\tLoad extra xml configuration, but don't commit.\n"
|
" -c <file>\tLoad extra xml configuration, but don't commit.\n"
|
||||||
" -g <group>\tClient membership required to this group (default: %s)\n"
|
" -g <group>\tClient membership required to this group (default: %s)\n"
|
||||||
" -l <s|e|o> \tLog on (s)yslog, std(e)rr or std(o)ut (stderr is default) Only valid if -F, if background syslog is on syslog.\n"
|
" -l <s|e|o|f<file>> \tLog on (s)yslog, std(e)rr or std(o)ut (stderr is default) Only valid if -F, if background syslog is on syslog.\n"
|
||||||
" -y <file>\tOverride yang spec file (dont include .yang suffix)\n"
|
" -y <file>\tOverride yang spec file (dont include .yang suffix)\n"
|
||||||
" -x <plugin>\tXMLDB plugin\n",
|
" -x <plugin>\tXMLDB plugin\n",
|
||||||
argv0,
|
argv0,
|
||||||
|
|
@ -598,6 +598,10 @@ main(int argc,
|
||||||
case 'l': /* Log destination: s|e|o */
|
case 'l': /* Log destination: s|e|o */
|
||||||
if ((logdst = clicon_log_opt(optarg[0])) < 0)
|
if ((logdst = clicon_log_opt(optarg[0])) < 0)
|
||||||
usage(h, argv[0]);
|
usage(h, argv[0]);
|
||||||
|
if (logdst == CLICON_LOG_FILE &&
|
||||||
|
strlen(optarg)>1 &&
|
||||||
|
clicon_log_file(optarg+1) < 0)
|
||||||
|
goto done;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
@ -607,8 +611,6 @@ main(int argc,
|
||||||
* XXX: if started in a start-daemon script, there will be irritating
|
* XXX: if started in a start-daemon script, there will be irritating
|
||||||
* double syslogs until fork below.
|
* double syslogs until fork below.
|
||||||
*/
|
*/
|
||||||
if ((logdst & CLICON_LOG_FILE) && clicon_log_file(BACKEND_LOGFILE) < 0)
|
|
||||||
goto done;
|
|
||||||
clicon_log_init(__PROGRAM__, debug?LOG_DEBUG:LOG_INFO, logdst);
|
clicon_log_init(__PROGRAM__, debug?LOG_DEBUG:LOG_INFO, logdst);
|
||||||
clicon_debug_init(debug, NULL);
|
clicon_debug_init(debug, NULL);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,7 @@ usage(clicon_handle h,
|
||||||
"\t-p \t\tPrint database yang specification\n"
|
"\t-p \t\tPrint database yang specification\n"
|
||||||
"\t-G \t\tPrint CLI syntax generated from dbspec (if CLICON_CLI_GENMODEL enabled)\n"
|
"\t-G \t\tPrint CLI syntax generated from dbspec (if CLICON_CLI_GENMODEL enabled)\n"
|
||||||
"\t-L \t\tDebug print dynamic CLI syntax including completions and expansions\n"
|
"\t-L \t\tDebug print dynamic CLI syntax including completions and expansions\n"
|
||||||
"\t-l <s|e|o> \tLog on (s)yslog, std(e)rr or std(o)ut (stderr is default)\n"
|
"\t-l <s|e|o|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut or (f)ile (stderr is default)\n"
|
||||||
"\t-y <file>\tOverride yang spec file (dont include .yang suffix)\n"
|
"\t-y <file>\tOverride yang spec file (dont include .yang suffix)\n"
|
||||||
"\t-c <file>\tSpecify cli spec file.\n"
|
"\t-c <file>\tSpecify cli spec file.\n"
|
||||||
"\t-U <user>\tOver-ride unix user with a pseudo user for NACM.\n",
|
"\t-U <user>\tOver-ride unix user with a pseudo user for NACM.\n",
|
||||||
|
|
@ -299,16 +299,18 @@ main(int argc, char **argv)
|
||||||
case 'x': /* dump config file as xml (migration from .conf file)*/
|
case 'x': /* dump config file as xml (migration from .conf file)*/
|
||||||
dump_configfile_xml++;
|
dump_configfile_xml++;
|
||||||
break;
|
break;
|
||||||
case 'l': /* Log destination: s|e|o */
|
case 'l': /* Log destination: s|e|o|f */
|
||||||
if ((logdst = clicon_log_opt(optarg[0])) < 0)
|
if ((logdst = clicon_log_opt(optarg[0])) < 0)
|
||||||
usage(h, argv[0]);
|
usage(h, argv[0]);
|
||||||
|
if (logdst == CLICON_LOG_FILE &&
|
||||||
|
strlen(optarg)>1 &&
|
||||||
|
clicon_log_file(optarg+1) < 0)
|
||||||
|
goto done;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Logs, error and debug to stderr or syslog, set debug level
|
* Logs, error and debug to stderr or syslog, set debug level
|
||||||
*/
|
*/
|
||||||
if ((logdst & CLICON_LOG_FILE) && clicon_log_file(CLI_LOGFILE) < 0)
|
|
||||||
goto done;
|
|
||||||
clicon_log_init(__PROGRAM__, debug?LOG_DEBUG:LOG_INFO, logdst);
|
clicon_log_init(__PROGRAM__, debug?LOG_DEBUG:LOG_INFO, logdst);
|
||||||
|
|
||||||
clicon_debug_init(debug, NULL);
|
clicon_debug_init(debug, NULL);
|
||||||
|
|
|
||||||
|
|
@ -299,7 +299,7 @@ usage(clicon_handle h,
|
||||||
"\t-D\t\tDebug\n"
|
"\t-D\t\tDebug\n"
|
||||||
"\t-q\t\tQuiet: dont send hello prompt\n"
|
"\t-q\t\tQuiet: dont send hello prompt\n"
|
||||||
"\t-f <file>\tConfiguration file (mandatory)\n"
|
"\t-f <file>\tConfiguration file (mandatory)\n"
|
||||||
"\t-l <s|f> \tLog on (s)yslog, (f)ile (syslog is default)\n"
|
"\t-l <e|o|s|f<file>> \tLog on std(e)rr, std(o)ut, (s)yslog, (f)ile (syslog is default)\n"
|
||||||
"\t-a UNIX|IPv4|IPv6\tInternal backend socket family\n"
|
"\t-a UNIX|IPv4|IPv6\tInternal backend socket family\n"
|
||||||
"\t-u <path|addr>\tInternal socket domain path or IP addr (see -a)\n"
|
"\t-u <path|addr>\tInternal socket domain path or IP addr (see -a)\n"
|
||||||
"\t-d <dir>\tSpecify netconf plugin directory dir (default: %s)\n"
|
"\t-d <dir>\tSpecify netconf plugin directory dir (default: %s)\n"
|
||||||
|
|
@ -355,13 +355,15 @@ main(int argc,
|
||||||
case 'l': /* Log destination: s|e|o */
|
case 'l': /* Log destination: s|e|o */
|
||||||
if ((logdst = clicon_log_opt(optarg[0])) < 0)
|
if ((logdst = clicon_log_opt(optarg[0])) < 0)
|
||||||
usage(h, argv[0]);
|
usage(h, argv[0]);
|
||||||
|
if (logdst == CLICON_LOG_FILE &&
|
||||||
|
strlen(optarg)>1 &&
|
||||||
|
clicon_log_file(optarg+1) < 0)
|
||||||
|
goto done;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Logs, error and debug to stderr or syslog, set debug level
|
* Logs, error and debug to stderr or syslog, set debug level
|
||||||
*/
|
*/
|
||||||
if ((logdst & CLICON_LOG_FILE) && clicon_log_file(NETCONF_LOGFILE) < 0)
|
|
||||||
goto done;
|
|
||||||
clicon_log_init(__PROGRAM__, debug?LOG_DEBUG:LOG_INFO, logdst);
|
clicon_log_init(__PROGRAM__, debug?LOG_DEBUG:LOG_INFO, logdst);
|
||||||
clicon_debug_init(debug, NULL);
|
clicon_debug_init(debug, NULL);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -490,7 +490,7 @@ usage(clicon_handle h,
|
||||||
"\t-h \t\tHelp\n"
|
"\t-h \t\tHelp\n"
|
||||||
"\t-D \t\tDebug. Log to syslog\n"
|
"\t-D \t\tDebug. Log to syslog\n"
|
||||||
"\t-f <file>\tConfiguration file (mandatory)\n"
|
"\t-f <file>\tConfiguration file (mandatory)\n"
|
||||||
"\t-l <s|f> \tLog on (s)yslog, (f)ile (syslog is default)\n"
|
"\t-l <s|f<file>> \tLog on (s)yslog, (f)ile (syslog is default)\n"
|
||||||
"\t-d <dir>\tSpecify restconf plugin directory dir (default: %s)\n"
|
"\t-d <dir>\tSpecify restconf plugin directory dir (default: %s)\n"
|
||||||
"\t-y <file>\tOverride yang spec file (dont include .yang suffix)\n"
|
"\t-y <file>\tOverride yang spec file (dont include .yang suffix)\n"
|
||||||
"\t-a UNIX|IPv4|IPv6\tInternal backend socket family\n"
|
"\t-a UNIX|IPv4|IPv6\tInternal backend socket family\n"
|
||||||
|
|
@ -543,14 +543,16 @@ main(int argc,
|
||||||
case 'l': /* Log destination: s|e|o */
|
case 'l': /* Log destination: s|e|o */
|
||||||
if ((logdst = clicon_log_opt(optarg[0])) < 0)
|
if ((logdst = clicon_log_opt(optarg[0])) < 0)
|
||||||
usage(h, argv[0]);
|
usage(h, argv[0]);
|
||||||
|
if (logdst == CLICON_LOG_FILE &&
|
||||||
|
strlen(optarg)>1 &&
|
||||||
|
clicon_log_file(optarg+1) < 0)
|
||||||
|
goto done;
|
||||||
break;
|
break;
|
||||||
} /* switch getopt */
|
} /* switch getopt */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Logs, error and debug to stderr or syslog, set debug level
|
* Logs, error and debug to stderr or syslog, set debug level
|
||||||
*/
|
*/
|
||||||
if ((logdst & CLICON_LOG_FILE) && clicon_log_file(RESTCONF_LOGFILE) < 0)
|
|
||||||
goto done;
|
|
||||||
clicon_log_init(__PROGRAM__, debug?LOG_DEBUG:LOG_INFO, logdst);
|
clicon_log_init(__PROGRAM__, debug?LOG_DEBUG:LOG_INFO, logdst);
|
||||||
|
|
||||||
clicon_debug_init(debug, NULL);
|
clicon_debug_init(debug, NULL);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue