diff --git a/CHANGELOG.md b/CHANGELOG.md index b28bc19a..19bb318d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/apps/backend/backend_main.c b/apps/backend/backend_main.c index 0fd10a22..7895fb45 100644 --- a/apps/backend/backend_main.c +++ b/apps/backend/backend_main.c @@ -448,7 +448,7 @@ usage(clicon_handle h, "\t-D \tDebug level\n" "\t-f \tClixon config file\n" "\t-E \tExtra configuration file directory\n" - "\t-l (s|e|o|f) 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\n" + "\t-l > \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n" "\t-d \tSpecify backend plugin directory (default: %s)\n" "\t-p \tAdd Yang directory path (see CLICON_YANG_DIR)\n" "\t-b \tSpecify datastore directory\n" diff --git a/apps/cli/cli_main.c b/apps/cli/cli_main.c index ca515331..b95c18dd 100644 --- a/apps/cli/cli_main.c +++ b/apps/cli/cli_main.c @@ -428,7 +428,7 @@ usage(clicon_handle h, "\t-p \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 > \tLog on (s)yslog, std(e)rr, std(o)ut or (f)ile (stderr is default)\n" + "\t-l > \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (stderr is default)\n" "\t-y \tOverride yang spec file (dont include .yang suffix)\n" "\t-c \tSpecify cli spec file.\n" "\t-U \tOver-ride unix user with a pseudo user for NACM.\n" diff --git a/apps/cli/cli_plugin.c b/apps/cli/cli_plugin.c index 725cd65b..30f16b40 100644 --- a/apps/cli/cli_plugin.c +++ b/apps/cli/cli_plugin.c @@ -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)); diff --git a/apps/netconf/netconf_main.c b/apps/netconf/netconf_main.c index ee83b258..6bc46d60 100644 --- a/apps/netconf/netconf_main.c +++ b/apps/netconf/netconf_main.c @@ -725,7 +725,7 @@ usage(clicon_handle h, "\t-D \tDebug level\n" "\t-f \tConfiguration file (mandatory)\n" "\t-E \tExtra configuration file directory\n" - "\t-l (e|o|s|f) Log on std(e)rr, std(o)ut, (s)yslog(default), (f)ile\n" + "\t-l > \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" diff --git a/apps/restconf/restconf_lib.c b/apps/restconf/restconf_lib.c index eea482de..355edd70 100644 --- a/apps/restconf/restconf_lib.c +++ b/apps/restconf/restconf_lib.c @@ -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) diff --git a/apps/restconf/restconf_main_fcgi.c b/apps/restconf/restconf_main_fcgi.c index 8890f3af..75cf08b3 100644 --- a/apps/restconf/restconf_main_fcgi.c +++ b/apps/restconf/restconf_main_fcgi.c @@ -268,7 +268,7 @@ usage(clicon_handle h, "\t-D \t Debug level\n" "\t-f \t Configuration file (mandatory)\n" "\t-E \t Extra configuration file directory\n" - "\t-l > \t Log on (s)yslog, (f)ile (syslog is default)\n" + "\t-l > \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n" "\t-p \t Yang directory path (see CLICON_YANG_DIR)\n" "\t-y \t Load yang spec file (override yang main module)\n" "\t-a UNIX|IPv4|IPv6 Internal backend socket family\n" diff --git a/apps/restconf/restconf_main_native.c b/apps/restconf/restconf_main_native.c index 9aebea56..efc44e6b 100644 --- a/apps/restconf/restconf_main_native.c +++ b/apps/restconf/restconf_main_native.c @@ -1402,7 +1402,7 @@ usage(clicon_handle h, "\t-D \t Debug level, overrides any config debug setting\n" "\t-f \t Configuration file (mandatory)\n" "\t-E \t Extra configuration file directory\n" - "\t-l > \t Log on (s)yslog, (f)ile (syslog is default)\n" + "\t-l > \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n" "\t-p \t Yang directory path (see CLICON_YANG_DIR)\n" "\t-y \t Load yang spec file (override yang main module)\n" "\t-a UNIX|IPv4|IPv6 Internal backend socket family\n" diff --git a/lib/src/clixon_log.c b/lib/src/clixon_log.c index ca29f54f..19444b33 100644 --- a/lib/src/clixon_log.c +++ b/lib/src/clixon_log.c @@ -138,6 +138,9 @@ clicon_log_opt(char c) case 'f': logdst = CLICON_LOG_FILE; break; + case 'n': + logdst = 0; + break; default: break; } diff --git a/test/test_cli_apipath.sh b/test/test_cli_apipath.sh index 51e301cc..2f9100db 100755 --- a/test/test_cli_apipath.sh +++ b/test/test_cli_apipath.sh @@ -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 example2: 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 example2: 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"