Logging fixes

* Fixed: [Error message seen twice in some cases](https://github.com/clicon/clixon/issues/325)
* Extended `-l` command-line option to all clixon commands with a `none` option, eg `-l n` directs logging to `dev/null`
This commit is contained in:
Olof hagsand 2022-04-30 11:28:56 +02:00
parent ef302f0c05
commit 5551d753ef
10 changed files with 17 additions and 9 deletions

View file

@ -89,6 +89,7 @@ Users may have to change how they access the system
### Minor features
* Extended `-l` command-line option to all clixon commands with a `none` option, eg `-l n` directs logging to `dev/null`
* [Adding feature to top level container doesn't work](https://github.com/clicon/clixon/issues/322)
* Instead of removing YANG which is disabled by `if-feature`, replace it with an yang `anydata` node.
* This means XML specified by such YANG is ignored, and it is not an error to access it
@ -111,6 +112,7 @@ Users may have to change how they access the system
### Corrected Bugs
* Fixed: [Error message seen twice in some cases](https://github.com/clicon/clixon/issues/325)
* Fixed: [if choice is declared with multiple elements or leaf-list with in a case scope , addition or updation is not happening as expected](https://github.com/clicon/clixon/issues/327)
* This includes several choice/case adjustments to follow RFC 7950 Sec 7.9 better
* Fixed: HTTP/1 parse error for '/' path

View file

@ -448,7 +448,7 @@ usage(clicon_handle h,
"\t-D <level>\tDebug level\n"
"\t-f <file>\tClixon config file\n"
"\t-E <dir> \tExtra configuration file directory\n"
"\t-l (s|e|o|f<file>) Log on (s)yslog, std(e)rr, std(o)ut or (f)ile. Syslog is default. If foreground, then syslog and stderr is default. Filename is given after -f as follows: -lf<file>\n"
"\t-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n"
"\t-d <dir>\tSpecify backend plugin directory (default: %s)\n"
"\t-p <dir>\tAdd Yang directory path (see CLICON_YANG_DIR)\n"
"\t-b <dir>\tSpecify datastore directory\n"

View file

@ -428,7 +428,7 @@ usage(clicon_handle h,
"\t-p <dir>\tYang directory path (see CLICON_YANG_DIR)\n"
"\t-G \t\tPrint auo-cli CLI syntax generated from YANG\n"
"\t-L \t\tDebug print dynamic CLI syntax including completions and expansions\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-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (stderr is default)\n"
"\t-y <file>\tOverride yang spec file (dont include .yang suffix)\n"
"\t-c <file>\tSpecify cli spec file.\n"
"\t-U <user>\tOver-ride unix user with a pseudo user for NACM.\n"

View file

@ -509,12 +509,15 @@ cli_plugin_finish(clicon_handle h)
/*! Help function to print a meaningful error string.
* Sometimes the libraries specify an error string, if so print that.
* Otherwise just print 'command error'.
* But do not print it if error is already logged in eg clicon_err() using STDERR logging
* See eg https://github.com/clicon/clixon/issues/325
* @param[in] f File handler to write error to.
*/
int
cli_handler_err(FILE *f)
{
if (clicon_errno){
if (clicon_errno &&
(clicon_get_logflags() & CLICON_LOG_STDERR) == 0){
fprintf(f, "%s: %s", clicon_strerror(clicon_errno), clicon_err_reason);
if (clicon_suberrno)
fprintf(f, ": %s", strerror(clicon_suberrno));

View file

@ -725,7 +725,7 @@ usage(clicon_handle h,
"\t-D <level>\tDebug level\n"
"\t-f <file>\tConfiguration file (mandatory)\n"
"\t-E <dir> \tExtra configuration file directory\n"
"\t-l (e|o|s|f<file>) Log on std(e)rr, std(o)ut, (s)yslog(default), (f)ile\n"
"\t-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (stderr is default)\n"
"\t-q\t\tServer does not send hello message on startup\n"
"\t-0 \t\tSet netconf base capability to 0, server does not expect hello, force EOM framing\n"
"\t-1 \t\tSet netconf base capability to 1, server does not expect hello, force chunked framing\n"

View file

@ -572,7 +572,7 @@ restconf_uripath(clicon_handle h)
/*! Drop privileges from root to user (or already at user)
* @param[in] h Clicon handle
* Group set to clicon to communicate with backend
* Group set to CLICON_SOCK_GROUP to communicate with backend
*/
int
restconf_drop_privileges(clicon_handle h)

View file

@ -268,7 +268,7 @@ usage(clicon_handle h,
"\t-D <level>\t Debug level\n"
"\t-f <file>\t Configuration file (mandatory)\n"
"\t-E <dir> \t Extra configuration file directory\n"
"\t-l <s|f<file>> \t Log on (s)yslog, (f)ile (syslog is default)\n"
"\t-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n"
"\t-p <dir>\t Yang directory path (see CLICON_YANG_DIR)\n"
"\t-y <file>\t Load yang spec file (override yang main module)\n"
"\t-a UNIX|IPv4|IPv6 Internal backend socket family\n"

View file

@ -1402,7 +1402,7 @@ usage(clicon_handle h,
"\t-D <level>\t Debug level, overrides any config debug setting\n"
"\t-f <file>\t Configuration file (mandatory)\n"
"\t-E <dir> \t Extra configuration file directory\n"
"\t-l <s|f<file>> \t Log on (s)yslog, (f)ile (syslog is default)\n"
"\t-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n"
"\t-p <dir>\t Yang directory path (see CLICON_YANG_DIR)\n"
"\t-y <file>\t Load yang spec file (override yang main module)\n"
"\t-a UNIX|IPv4|IPv6 Internal backend socket family\n"

View file

@ -138,6 +138,9 @@ clicon_log_opt(char c)
case 'f':
logdst = CLICON_LOG_FILE;
break;
case 'n':
logdst = 0;
break;
default:
break;
}

View file

@ -107,10 +107,10 @@ expectpart "$($clixon_cli -1 -f $cfg show conf x)" 0 "x m1 a 22 b 33"
# Negative tests
new "err x"
expectpart "$($clixon_cli -1 -f $cfg err x)" 255 "Config error: api-path syntax error \"/example2:x\": application unknown-element No such yang module prefix <bad-element>example2</bad-element>: Invalid argument"
expectpart "$($clixon_cli -1 -f $cfg -l n err x)" 255 "Config error: api-path syntax error \"/example2:x\": application unknown-element No such yang module prefix <bad-element>example2</bad-element>: Invalid argument"
new "err x a"
expectpart "$($clixon_cli -1 -f $cfg err x a 99)" 255 "Config error: api-path syntax error \"/example:x/m1=%s\": rpc malformed-message List key m1 length mismatch : Invalid argument"
expectpart "$($clixon_cli -1 -f $cfg -l n err x a 99)" 255 "Config error: api-path syntax error \"/example:x/m1=%s\": rpc malformed-message List key m1 length mismatch : Invalid argument"
if [ $BE -ne 0 ]; then
new "Kill backend"