diff --git a/CHANGELOG.md b/CHANGELOG.md
index c8111bda..618c2ccc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,11 @@ Expected: February 2024
### Minor features
+* New command-line debug mechanism
+ * Separation between subject-area and details
+ * Multiple subject-areas
+ * Symbolic and combined debug names, example: `-D debug -D detail`
+ * See https://clixon-docs.readthedocs.io/en/latest/errors.html#customized-errors for more info
* Made coverity analysis and fixed most of them
* Some were ignored being for generated code (eg lex) or not applicable
* Feature: [Add support for -V option to give version](https://github.com/clicon/clixon/issues/472)
diff --git a/apps/backend/backend_client.c b/apps/backend/backend_client.c
index 887653ce..d5ef5e60 100644
--- a/apps/backend/backend_client.c
+++ b/apps/backend/backend_client.c
@@ -146,7 +146,7 @@ ce_event_cb(clixon_handle h,
struct client_entry *ce = (struct client_entry *)arg;
cbuf *cbce = NULL;
- clixon_debug(CLIXON_DBG_CLIENT, "op:%d", op);
+ clixon_debug(CLIXON_DBG_BACKEND, "op:%d", op);
switch (op){
case 1:
/* Risk of recursion here */
@@ -282,7 +282,7 @@ backend_monitoring_state_get(clixon_handle h,
goto fail;
retval = 1;
done:
- clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval);
+ clixon_debug(CLIXON_DBG_BACKEND, "retval:%d", retval);
if (cb)
cbuf_free(cb);
return retval;
@@ -321,10 +321,10 @@ backend_client_rm(clixon_handle h,
if (if_feature(yspec, "ietf-netconf", "confirmed-commit")) {
if (confirmed_commit_state_get(h) == EPHEMERAL) {
/* See if this client is the origin */
- clixon_debug(CLIXON_DBG_CLIENT, "session_id: %u, confirmed_commit.session_id: %u", ce->ce_id, confirmed_commit_session_id_get(h));
+ clixon_debug(CLIXON_DBG_BACKEND, "session_id: %u, confirmed_commit.session_id: %u", ce->ce_id, confirmed_commit_session_id_get(h));
if (myid == confirmed_commit_session_id_get(h)) {
- clixon_debug(CLIXON_DBG_CLIENT, "ok, rolling back");
+ clixon_debug(CLIXON_DBG_BACKEND, "ok, rolling back");
clixon_log(h, LOG_NOTICE, "a client with an active ephemeral confirmed-commit has disconnected; rolling back");
/* do_rollback errors are logged internally and there is no client to report errors to, so errors are
@@ -336,7 +336,7 @@ backend_client_rm(clixon_handle h,
}
}
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_BACKEND, "");
/* for all streams: XXX better to do it top-level? */
stream_ss_delete_all(h, ce_event_cb, (void*)ce);
c0 = backend_client_list(h);
@@ -378,7 +378,7 @@ clixon_stats_datastore_get(clixon_handle h,
size_t sz = 0;
cxobj *xn = NULL;
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "%s", dbname);
+ clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "%s", dbname);
/* This is the db cache */
if ((xt = xmldb_cache_get(h, dbname)) == NULL){
/* Trigger cache if no exist (trick to ensure cache is present) */
@@ -655,7 +655,7 @@ from_client_edit_config(clixon_handle h,
xml_free(xret);
if (cbx)
cbuf_free(cbx);
- clixon_debug(CLIXON_DBG_CLIENT, "done cbret:%s", cbuf_get(cbret));
+ clixon_debug(CLIXON_DBG_BACKEND, "done cbret:%s", cbuf_get(cbret));
return retval;
} /* from_client_edit_config */
@@ -1584,7 +1584,7 @@ from_client_msg(clixon_handle h,
int nr = 0;
cbuf *cbce = NULL;
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "");
+ clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
yspec = clicon_dbspec_yang(h);
/* Return netconf message. Should be filled in by the dispatch(sub) functions
* as wither rpc-error or by positive response.
@@ -1633,7 +1633,7 @@ from_client_msg(clixon_handle h,
if (op_id != 0 && ce->ce_id != op_id && strcmp(rpcname, "create-subscription")){
client_entry *ce0;
- clixon_debug(CLIXON_DBG_CLIENT, "Warning: incoming session-id:%u does not match ce_id:%u on socket: %d", op_id, ce->ce_id, ce->ce_s);
+ clixon_debug(CLIXON_DBG_BACKEND, "Warning: incoming session-id:%u does not match ce_id:%u on socket: %d", op_id, ce->ce_id, ce->ce_s);
/* Copy transport from orig client-entry */
if (ce->ce_transport == NULL &&
(ce0 = ce_find_byid(backend_client_list(h), op_id)) != NULL &&
@@ -1720,7 +1720,7 @@ from_client_msg(clixon_handle h,
goto done;
}
module = yang_argument_get(ymod);
- clixon_debug(CLIXON_DBG_CLIENT, "module:%s rpc:%s ce_id:%u s:%d", module,
+ clixon_debug(CLIXON_DBG_BACKEND, "module:%s rpc:%s ce_id:%u s:%d", module,
rpc, ce->ce_id, ce->ce_s);
/* Pre-NACM access step */
xnacm = NULL;
@@ -1812,7 +1812,7 @@ from_client_msg(clixon_handle h,
// ok:
retval = 0;
done:
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "retval:%d", retval);
+ clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "retval:%d", retval);
if (xnacm){
xml_free(xnacm);
if (clicon_nacm_cache_set(h, NULL) < 0)
@@ -1830,7 +1830,7 @@ from_client_msg(clixon_handle h,
if (retval < 0 && clixon_err_category() < 0)
clixon_log(h, LOG_NOTICE, "%s: Internal error: No clixon_err call on RPC error (message: %s)",
__FUNCTION__, rpc?rpc:"");
- // clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval);
+ // clixon_debug(CLIXON_DBG_BACKEND, "retval:%d", retval);
return retval;// -1 here terminates backend
}
@@ -1853,7 +1853,7 @@ from_client(int s,
int eof = 0;
cbuf *cbce = NULL;
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "");
+ clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
if (s != ce->ce_s){
clixon_err(OE_NETCONF, EINVAL, "Internal error: s != ce->ce_s");
goto done;
@@ -1871,7 +1871,7 @@ from_client(int s,
goto done;
retval = 0;
done:
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "retval:%d", retval);
+ clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "retval:%d", retval);
if (cbce)
cbuf_free(cbce);
if (msg)
diff --git a/apps/backend/backend_commit.c b/apps/backend/backend_commit.c
index 2f27a9f3..7d5b60c5 100644
--- a/apps/backend/backend_commit.c
+++ b/apps/backend/backend_commit.c
@@ -178,7 +178,7 @@ startup_common(clixon_handle h,
if (clicon_option_bool(h, "CLICON_XMLDB_MODSTATE"))
if ((msdiff = modstate_diff_new()) == NULL)
goto done;
- clixon_debug(CLIXON_DBG_CLIENT, "Reading initial config from %s", db);
+ clixon_debug(CLIXON_DBG_BACKEND, "Reading initial config from %s", db);
/* Get the startup datastore WITHOUT binding to YANG, sorting and default setting.
* It is done below, later in this function
*/
@@ -203,7 +203,7 @@ startup_common(clixon_handle h,
if (xmldb_get0(h, db, YB_NONE, NULL, "/", 0, 0, &xt, msdiff, &xerr) < 0)
goto done;
}
- clixon_debug_xml(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, xt, "startup");
+ clixon_debug_xml(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, xt, "startup");
if (msdiff && msdiff->md_status == 0){ // Possibly check for CLICON_XMLDB_MODSTATE
clixon_log(h, LOG_WARNING, "Modstate expected in startup datastore but not found\n"
"This may indicate that the datastore is not initialized corrrectly, such as copy/pasted.\n"
@@ -213,7 +213,7 @@ startup_common(clixon_handle h,
clixon_err(OE_YANG, 0, "Yang spec not set");
goto done;
}
- clixon_debug(CLIXON_DBG_CLIENT, "Reading startup config done");
+ clixon_debug(CLIXON_DBG_BACKEND, "Reading startup config done");
/* Clear flags xpath for get */
xml_apply0(xt, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset,
(void*)(XML_FLAG_MARK|XML_FLAG_CHANGE));
@@ -302,7 +302,7 @@ startup_common(clixon_handle h,
/* 5. Make generic validation on all new or changed data.
Note this is only call that uses 3-values */
- clixon_debug(CLIXON_DBG_CLIENT, "Validating startup %s", db);
+ clixon_debug(CLIXON_DBG_BACKEND, "Validating startup %s", db);
if ((ret = generic_validate(h, yspec, td, &xret)) < 0)
goto done;
if (ret == 0){
@@ -584,7 +584,7 @@ candidate_validate(clixon_handle h,
cxobj *xret = NULL;
int ret;
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_BACKEND, "");
if (db == NULL || cbret == NULL){
clixon_err(OE_CFG, EINVAL, "db or cbret is NULL");
goto done;
@@ -801,14 +801,14 @@ from_client_commit(clixon_handle h,
goto ok;
}
if ((ret = candidate_commit(h, xe, "candidate", myid, 0, cbret)) < 0){ /* Assume validation fail, nofatal */
- clixon_debug(CLIXON_DBG_CLIENT, "Commit candidate failed");
+ clixon_debug(CLIXON_DBG_BACKEND, "Commit candidate failed");
if (ret < 0)
if (netconf_operation_failed(cbret, "application", clixon_err_reason())< 0)
goto done;
goto ok;
}
if (ret == 0)
- clixon_debug(CLIXON_DBG_CLIENT, "Commit candidate failed");
+ clixon_debug(CLIXON_DBG_BACKEND, "Commit candidate failed");
else
cprintf(cbret, "", NETCONF_BASE_NAMESPACE);
ok:
@@ -892,7 +892,7 @@ from_client_validate(clixon_handle h,
int ret;
char *db;
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_BACKEND, "");
if ((db = netconf_db_find(xe, "source")) == NULL){
if (netconf_missing_element(cbret, "protocol", "source", NULL) < 0)
goto done;
@@ -938,7 +938,7 @@ from_client_restart_one(clixon_handle h,
if (clixon_resource_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
goto done;
if ((retval = resetfn(h, db)) < 0) {
- clixon_debug(CLIXON_DBG_CLIENT, "plugin_start() failed");
+ clixon_debug(CLIXON_DBG_BACKEND, "plugin_start() failed");
goto done;
}
if (clixon_resource_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
diff --git a/apps/backend/backend_confirm.c b/apps/backend/backend_confirm.c
index 52634d5f..5498bcbb 100644
--- a/apps/backend/backend_confirm.c
+++ b/apps/backend/backend_confirm.c
@@ -455,7 +455,7 @@ check_valid_confirming_commit(clixon_handle h,
"not issued on the same session as the confirmed-commit");
goto invalid;
default:
- clixon_debug(CLIXON_DBG_CLIENT, "commit-confirmed state !? %d", confirmed_commit_state_get(h));
+ clixon_debug(CLIXON_DBG_BACKEND, "commit-confirmed state !? %d", confirmed_commit_state_get(h));
goto invalid;
}
retval = 1; // valid
diff --git a/apps/backend/backend_get.c b/apps/backend/backend_get.c
index c71173b8..947acc2b 100644
--- a/apps/backend/backend_get.c
+++ b/apps/backend/backend_get.c
@@ -207,7 +207,7 @@ get_statedata(clixon_handle h,
cbuf *cb = NULL;
cxobj *xerr = NULL;
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_BACKEND, "");
if ((yspec = clicon_dbspec_yang(h)) == NULL){
clixon_err(OE_YANG, ENOENT, "No yang spec");
goto done;
@@ -312,7 +312,7 @@ get_statedata(clixon_handle h,
goto fail;
retval = 1; /* OK */
done:
- clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval);
+ clixon_debug(CLIXON_DBG_BACKEND, "retval:%d", retval);
if (xerr)
xml_free(xerr);
if (x1)
@@ -709,7 +709,7 @@ get_list_pagination(clixon_handle h,
if ((ret = xml_bind_yang(h, xret, YB_MODULE, yspec, &xerr)) < 0)
goto done;
if (ret == 0){
- clixon_debug_xml(CLIXON_DBG_CLIENT, xret, "Yang bind pagination state");
+ clixon_debug_xml(CLIXON_DBG_BACKEND, xret, "Yang bind pagination state");
if (clixon_netconf_internal_error(xerr,
". Internal error, state callback returned invalid XML",
NULL) < 0)
@@ -812,7 +812,7 @@ get_common(clixon_handle h,
char *wdefstr;
wdef = WITHDEFAULTS_EXPLICIT;
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "");
+ clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
username = clicon_username_get(h);
if ((yspec = clicon_dbspec_yang(h)) == NULL){
clixon_err(OE_YANG, ENOENT, "No yang spec9");
@@ -965,7 +965,7 @@ get_common(clixon_handle h,
(ret = xml_yang_validate_add(h, xret, &xerr)) < 0)
goto done;
if (ret == 0){
- clixon_debug_xml(CLIXON_DBG_CLIENT, xret, "VALIDATE_STATE");
+ clixon_debug_xml(CLIXON_DBG_BACKEND, xret, "VALIDATE_STATE");
if (clixon_netconf_internal_error(xerr,
". Internal error, state callback returned invalid XML",
NULL) < 0)
@@ -996,7 +996,7 @@ get_common(clixon_handle h,
ok:
retval = 0;
done:
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "retval:%d", retval);
+ clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "retval:%d", retval);
if (xvec)
free(xvec);
if (xret)
diff --git a/apps/backend/backend_main.c b/apps/backend/backend_main.c
index a0ad0a27..f0c2f824 100644
--- a/apps/backend/backend_main.c
+++ b/apps/backend/backend_main.c
@@ -100,7 +100,7 @@ backend_terminate(clixon_handle h)
int ss;
cvec *nsctx;
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_BACKEND, "");
if ((ss = clicon_socket_get(h)) != -1)
close(ss);
/* Disconnect datastore */
@@ -142,7 +142,7 @@ backend_terminate(clixon_handle h)
if (sockfamily==AF_UNIX && lstat(sockpath, &st) == 0)
unlink(sockpath);
clixon_event_exit();
- clixon_debug(CLIXON_DBG_CLIENT, "done");
+ clixon_debug(CLIXON_DBG_BACKEND, "done");
clixon_err_exit();
clixon_log_exit();
backend_handle_exit(h); /* Also deletes streams. Cannot use h after this. */
@@ -172,7 +172,7 @@ backend_sig_term(int arg)
static void
backend_sig_child(int arg)
{
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_BACKEND, "");
clicon_sig_child_set(1);
}
@@ -428,7 +428,7 @@ backend_timer_setup(int fd,
struct timeval t;
struct timeval t1 = {10, 0};
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_BACKEND, "");
gettimeofday(&now, NULL);
backend_client_print(h, stderr);
@@ -463,7 +463,7 @@ usage(clixon_handle h,
"where options are\n"
"\t-h\t\tHelp\n"
"\t-V \t\tPrint version and exit\n"
- "\t-D \tDebug level\n"
+ "\t-D \tDebug level (see available levels below)\n"
"\t-f \tClixon config file\n"
"\t-E \tExtra configuration file directory\n"
"\t-l > \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n"
@@ -491,6 +491,9 @@ usage(clixon_handle h,
confpid ? confpid : "none",
group ? group : "none"
);
+ fprintf(stderr, "Debug keys: ");
+ clixon_debug_key_dump(stderr);
+ fprintf(stderr, "\n");
exit(-1);
}
@@ -569,10 +572,16 @@ main(int argc,
cligen_output(stdout, "Clixon version %s\n", CLIXON_VERSION_STRING);
print_version++; /* plugins may also print versions w ca-version callback */
break;
- case 'D' : /* debug */
- if (sscanf(optarg, "%d", &dbg) != 1)
+ case 'D' : { /* debug */
+ int d = 0;
+ /* 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;
+ }
case 'f': /* config file */
if (!strlen(optarg))
usage(h, argv[0]);
diff --git a/apps/backend/backend_plugin.c b/apps/backend/backend_plugin.c
index f21de728..63039e3d 100644
--- a/apps/backend/backend_plugin.c
+++ b/apps/backend/backend_plugin.c
@@ -117,7 +117,7 @@ clixon_plugin_reset_all(clixon_handle h,
int retval = -1;
clixon_plugin_t *cp = NULL;
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "");
+ clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
/* Loop through all plugins, call callbacks in each */
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
if (clixon_plugin_reset_one(cp, h, db) < 0)
@@ -179,7 +179,7 @@ clixon_plugin_pre_daemon_all(clixon_handle h)
int retval = -1;
clixon_plugin_t *cp = NULL;
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "");
+ clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
/* Loop through all plugins, call callbacks in each */
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
if (clixon_plugin_pre_daemon_one(cp, h) < 0)
@@ -242,7 +242,7 @@ clixon_plugin_daemon_all(clixon_handle h)
int retval = -1;
clixon_plugin_t *cp = NULL;
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "");
+ clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
/* Loop through all plugins, call callbacks in each */
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
if (clixon_plugin_daemon_one(cp, h) < 0)
@@ -346,7 +346,7 @@ clixon_plugin_statedata_all(clixon_handle h,
cbuf *cberr = NULL;
cxobj *xerr = NULL;
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "");
+ clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
if ((ret = clixon_plugin_statedata_one(cp, h, nsc, xpath, &x)) < 0)
goto done;
@@ -372,7 +372,7 @@ clixon_plugin_statedata_all(clixon_handle h,
x = NULL;
continue;
}
- clixon_debug_xml(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, x, "%s STATE:", clixon_plugin_name_get(cp));
+ clixon_debug_xml(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, x, "%s STATE:", clixon_plugin_name_get(cp));
/* XXX: ret == 0 invalid yang binding should be handled as internal error */
if ((ret = xml_bind_yang(h, x, YB_MODULE, yspec, &xerr)) < 0)
goto done;
@@ -472,7 +472,7 @@ clixon_plugin_lockdb_all(clixon_handle h,
int retval = -1;
clixon_plugin_t *cp = NULL;
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "");
+ clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
if (clixon_plugin_lockdb_one(cp, h, db, lock, id) < 0)
goto done;
@@ -656,7 +656,7 @@ plugin_transaction_begin_all(clixon_handle h,
int retval = -1;
clixon_plugin_t *cp = NULL;
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "");
+ clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
if (plugin_transaction_begin_one(cp, h, td) < 0)
goto done;
@@ -1002,7 +1002,7 @@ plugin_transaction_end_all(clixon_handle h,
int retval = -1;
clixon_plugin_t *cp = NULL;
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "");
+ clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
if (plugin_transaction_end_one(cp, h, td) < 0)
goto done;
@@ -1055,7 +1055,7 @@ plugin_transaction_abort_all(clixon_handle h,
int retval = -1;
clixon_plugin_t *cp = NULL;
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "");
+ clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
if (plugin_transaction_abort_one(cp, h, td) < 0)
; /* dont abort on error */
diff --git a/apps/backend/backend_plugin_restconf.c b/apps/backend/backend_plugin_restconf.c
index 5496bbbb..b22a0225 100644
--- a/apps/backend/backend_plugin_restconf.c
+++ b/apps/backend/backend_plugin_restconf.c
@@ -154,7 +154,7 @@ restconf_pseudo_set_inline(clixon_handle h,
cxobj *xrestconf;
cbuf *cb = NULL;
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_BACKEND, "");
if (clixon_process_argv_get(h, RESTCONF_PROCESS, &argv, &argc) < 0)
goto done;
if ((xrestconf = xpath_first(xt, NULL, "restconf")) != NULL)
@@ -174,7 +174,7 @@ restconf_pseudo_set_inline(clixon_handle h,
clixon_err(OE_XML, errno, "stdup");
goto done;
}
- clixon_debug(CLIXON_DBG_CLIENT, "str:%s", str);
+ clixon_debug(CLIXON_DBG_BACKEND, "str:%s", str);
if (argv[i+1])
free(argv[i+1]);
argv[i+1] = str;
@@ -203,7 +203,7 @@ restconf_rpc_wrapper(clixon_handle h,
int retval = -1;
cxobj *xt = NULL;
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_BACKEND, "");
switch (*operation){
case PROC_OP_STOP:
/* if RPC op is stop, stop the service */
@@ -283,24 +283,24 @@ restconf_pseudo_process_control(clixon_handle h)
cprintf(cb, "%s/clixon_restconf", dir0);
pgm = cbuf_get(cb);
if (stat(pgm, &fstat) == 0){ /* Sanity check: program exists */
- clixon_debug(CLIXON_DBG_CLIENT, "Found %s", pgm);
+ clixon_debug(CLIXON_DBG_BACKEND, "Found %s", pgm);
found++;
}
else
- clixon_debug(CLIXON_DBG_CLIENT, "Not found: %s", pgm);
+ clixon_debug(CLIXON_DBG_BACKEND, "Not found: %s", pgm);
}
if (!found &&
(dir1 = CLIXON_CONFIG_SBINDIR) != NULL){
cbuf_reset(cb);
cprintf(cb, "%s/clixon_restconf", dir1);
pgm = cbuf_get(cb);
- clixon_debug(CLIXON_DBG_CLIENT, "Looking for %s", pgm);
+ clixon_debug(CLIXON_DBG_BACKEND, "Looking for %s", pgm);
if (stat(pgm, &fstat) == 0){ /* Sanity check: program exists */
- clixon_debug(CLIXON_DBG_CLIENT, "Found %s", pgm);
+ clixon_debug(CLIXON_DBG_BACKEND, "Found %s", pgm);
found++;
}
else
- clixon_debug(CLIXON_DBG_CLIENT, "Not found: %s", pgm);
+ clixon_debug(CLIXON_DBG_BACKEND, "Not found: %s", pgm);
}
if (!found){
clixon_err(OE_RESTCONF, 0, "clixon_restconf not found in neither CLICON_RESTCONF_INSTALLDIR(%s) nor CLIXON_CONFIG_SBINDIR(%s). Try overriding with CLICON_RESTCONF_INSTALLDIR",
@@ -349,7 +349,7 @@ restconf_pseudo_process_validate(clixon_handle h,
int retval = -1;
cxobj *xtarget;
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_BACKEND, "");
xtarget = transaction_target(td);
/* If ssl-enable is true and (at least a) socket has ssl,
* then server-cert-path and server-key-path must exist */
@@ -381,7 +381,7 @@ restconf_pseudo_process_commit(clixon_handle h,
cxobj *cx;
int enabled = 0;
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_BACKEND, "");
xtarget = transaction_target(td);
xsource = transaction_src(td);
if (xpath_first(xtarget, NULL, "/restconf[enable='true']") != NULL)
diff --git a/apps/backend/backend_socket.c b/apps/backend/backend_socket.c
index 7a549d2e..58e78fe5 100644
--- a/apps/backend/backend_socket.c
+++ b/apps/backend/backend_socket.c
@@ -111,7 +111,7 @@ config_socket_init_ipv4(clixon_handle h,
clixon_err(OE_UNIX, errno, "bind");
goto err;
}
- clixon_debug(CLIXON_DBG_CLIENT, "Listen on server socket at %s:%hu", dst, port);
+ clixon_debug(CLIXON_DBG_BACKEND, "Listen on server socket at %s:%hu", dst, port);
if (listen(s, 5) < 0){
clixon_err(OE_UNIX, errno, "listen");
goto err;
@@ -178,7 +178,7 @@ config_socket_init_unix(clixon_handle h,
clixon_err(OE_UNIX, errno, "lchown(%s, %s)", sock, config_group);
goto err;
}
- clixon_debug(CLIXON_DBG_CLIENT, "Listen on server socket at %s", addr.sun_path);
+ clixon_debug(CLIXON_DBG_BACKEND, "Listen on server socket at %s", addr.sun_path);
if (listen(s, 5) < 0){
clixon_err(OE_UNIX, errno, "listen");
goto err;
@@ -245,7 +245,7 @@ backend_accept_client(int fd,
uid_t guid;
#endif
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "");
+ clixon_debug(CLIXON_DBG_BACKEND | CLIXON_DBG_DETAIL, "");
len = sizeof(from);
if ((s = accept(fd, &from, &len)) < 0){
clixon_err(OE_UNIX, errno, "accept");
diff --git a/apps/cli/cli_auto.c b/apps/cli/cli_auto.c
index c935519e..5e3b389e 100644
--- a/apps/cli/cli_auto.c
+++ b/apps/cli/cli_auto.c
@@ -137,7 +137,7 @@ cli_auto_edit(clixon_handle h,
str = cv_string_get(cvec_i(argv, argc++));
if (str && strncmp(str, "mtpoint:", strlen("mtpoint:")) == 0){
mtpoint = str + strlen("mtpoint:");
- clixon_debug(CLIXON_DBG_CLIENT, "mtpoint:%s", mtpoint);
+ clixon_debug(CLIXON_DBG_CLI, "mtpoint:%s", mtpoint);
treename = cv_string_get(cvec_i(argv, argc++));
}
else
diff --git a/apps/cli/cli_common.c b/apps/cli/cli_common.c
index e31628e9..7feae119 100644
--- a/apps/cli/cli_common.c
+++ b/apps/cli/cli_common.c
@@ -884,7 +884,7 @@ cli_commit(clixon_handle h,
cancel = (cvec_find_str(cvv, "cancel") != NULL);
if ((timeout_var = cvec_find(cvv, "timeout")) != NULL) {
timeout = cv_uint32_get(timeout_var);
- clixon_debug(CLIXON_DBG_CLIENT, "commit confirmed with timeout %ul", timeout);
+ clixon_debug(CLIXON_DBG_CLI, "commit confirmed with timeout %ul", timeout);
}
persist = cvec_find_str(cvv, "persist-val");
persist_id = cvec_find_str(cvv, "persist-id-val");
diff --git a/apps/cli/cli_generate.c b/apps/cli/cli_generate.c
index 1a665fcb..9ef56b59 100644
--- a/apps/cli/cli_generate.c
+++ b/apps/cli/cli_generate.c
@@ -1266,11 +1266,11 @@ yang2cli_stmt(clixon_handle h,
goto done;
}
if (yang_find(ys, Y_STATUS, "obsolete") != NULL){
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "obsolete: %s %s, skipped", yang_argument_get(ys), yang_argument_get(ys_module(ys)));
+ clixon_debug(CLIXON_DBG_CLI | CLIXON_DBG_DETAIL, "obsolete: %s %s, skipped", yang_argument_get(ys), yang_argument_get(ys_module(ys)));
goto ok;
}
if (yang_find(ys, Y_STATUS, "deprecated") != NULL){
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "deprecated: %s %s", yang_argument_get(ys), yang_argument_get(ys_module(ys)));
+ clixon_debug(CLIXON_DBG_CLI | CLIXON_DBG_DETAIL, "deprecated: %s %s", yang_argument_get(ys), yang_argument_get(ys_module(ys)));
}
/* Check if autocli skip */
if (yang_extension_value(ys, "skip", CLIXON_AUTOCLI_NS, &extvalue, NULL) < 0)
@@ -1543,11 +1543,11 @@ yang2cli_grouping(clixon_handle h,
}
/* Traverse YANG, loop through all modules and generate CLI, inline of yang2cli_stmt */
if (yang_find(ys, Y_STATUS, "obsolete") != NULL){
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "obsolete: %s %s, skipped", yang_argument_get(ys), yang_argument_get(ys_module(ys)));
+ clixon_debug(CLIXON_DBG_CLI | CLIXON_DBG_DETAIL, "obsolete: %s %s, skipped", yang_argument_get(ys), yang_argument_get(ys_module(ys)));
goto empty;
}
if (yang_find(ys, Y_STATUS, "deprecated") != NULL){
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "deprecated: %s %s", yang_argument_get(ys), yang_argument_get(ys_module(ys)));
+ clixon_debug(CLIXON_DBG_CLI | CLIXON_DBG_DETAIL, "deprecated: %s %s", yang_argument_get(ys), yang_argument_get(ys_module(ys)));
}
/* Only produce autocli for YANG non-config only if autocli-treeref-state is true */
if (autocli_treeref_state(h, &treeref_state) < 0)
@@ -1576,12 +1576,12 @@ yang2cli_grouping(clixon_handle h,
fprintf(stderr, "%s\n", cbuf_get(cb));
goto done;
}
- clixon_debug(CLIXON_DBG_CLIENT, "Generated auto-cli for grouping:%s",
+ clixon_debug(CLIXON_DBG_CLI, "Generated auto-cli for grouping:%s",
yang_argument_get(ys));
/* Add prefix: assume new are appended */
for (i=0; ico_command);
co_prefix_set(co, prefix);
}
@@ -1599,7 +1599,7 @@ yang2cli_grouping(clixon_handle h,
clixon_log(h, LOG_NOTICE, "%s: Top-level cli-spec %s:\n%s",
__FUNCTION__, treename, cbuf_get(cb));
else
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "Top-level cli-spec %s:\n%s",
+ clixon_debug(CLIXON_DBG_CLI | CLIXON_DBG_DETAIL, "Top-level cli-spec %s:\n%s",
treename, cbuf_get(cb));
if (cligen_parsetree_merge(pt0, NULL, pt) < 0){
clixon_err(OE_YANG, errno, "cligen_parsetree_merge");
@@ -1706,12 +1706,12 @@ yang2cli_yspec(clixon_handle h,
fprintf(stderr, "%s\n", cbuf_get(cb));
goto done;
}
- clixon_debug(CLIXON_DBG_CLIENT, "Generated auto-cli for module:%s",
+ clixon_debug(CLIXON_DBG_CLI, "Generated auto-cli for module:%s",
yang_argument_get(ymod));
/* Add prefix: assume new are appended */
for (i=0; ico_command);
co_prefix_set(co, prefix);
}
@@ -1730,7 +1730,7 @@ yang2cli_yspec(clixon_handle h,
clixon_log(h, LOG_NOTICE, "%s: Top-level cli-spec %s:\n%s",
__FUNCTION__, treename, cbuf_get(cb));
else
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "Top-level cli-spec %s:\n%s",
+ clixon_debug(CLIXON_DBG_CLI | CLIXON_DBG_DETAIL, "Top-level cli-spec %s:\n%s",
treename, cbuf_get(cb));
if (cligen_parsetree_merge(pt0, NULL, pt) < 0){
clixon_err(OE_YANG, errno, "cligen_parsetree_merge");
diff --git a/apps/cli/cli_main.c b/apps/cli/cli_main.c
index 65a11fb5..543f5bc4 100644
--- a/apps/cli/cli_main.c
+++ b/apps/cli/cli_main.c
@@ -391,7 +391,7 @@ autocli_start(clixon_handle h)
yang_stmt *yspec;
int enable = 0;
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_CLI, "");
/* There is no single "enable-autocli" flag,
* but set
* false
@@ -402,7 +402,7 @@ autocli_start(clixon_handle h)
if (autocli_module(h, NULL, &enable) < 0)
goto done;
if (!enable){
- clixon_debug(CLIXON_DBG_CLIENT, "Autocli not enabled (clixon-autocli)");
+ clixon_debug(CLIXON_DBG_CLI, "Autocli not enabled (clixon-autocli)");
goto ok;
}
/* Init yang2cli */
@@ -481,7 +481,7 @@ usage(clixon_handle h,
"where options are\n"
"\t-h \t\tHelp\n"
"\t-V \t\tPrint version and exit\n"
- "\t-D \tDebug level\n"
+ "\t-D \tDebug level (see available levels below)\n"
"\t-f \tConfig-file (mandatory)\n"
"\t-E \tExtra configuration file directory\n"
"\t-l > \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (stderr is default)\n"
@@ -496,7 +496,6 @@ usage(clixon_handle h,
"\t-p \tYang directory path (see CLICON_YANG_DIR)\n"
"\t-G \t\tPrint auto-cli CLI syntax generated from YANG\n"
"\t-L \t\tDebug print dynamic CLI syntax including completions and expansions\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"
@@ -504,6 +503,9 @@ usage(clixon_handle h,
argv0,
plgdir ? plgdir : "none"
);
+ fprintf(stderr, "Debug keys: ");
+ clixon_debug_key_dump(stderr);
+ fprintf(stderr, "\n");
exit(1);
}
@@ -581,10 +583,16 @@ main(int argc,
cligen_output(stdout, "Clixon version %s\n", CLIXON_VERSION_STRING);
print_version++; /* plugins may also print versions w ca-version callback */
break;
- case 'D' : /* debug */
- if (sscanf(optarg, "%d", &dbg) != 1)
+ case 'D' : { /* debug */
+ int d = 0;
+ /* 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;
+ }
case 'f': /* config file */
if (!strlen(optarg))
usage(h, argv[0]);
diff --git a/apps/cli/cli_plugin.c b/apps/cli/cli_plugin.c
index 2e916ffc..93139822 100644
--- a/apps/cli/cli_plugin.c
+++ b/apps/cli/cli_plugin.c
@@ -417,7 +417,7 @@ clispec_load(clixon_handle h)
goto done;
/* Load the syntax parse trees into cli_syntax stx structure */
for (i = 0; i < ndp; i++) {
- clixon_debug(CLIXON_DBG_CLIENT, "Loading clispec syntax: '%s/%s'",
+ clixon_debug(CLIXON_DBG_CLI, "Loading clispec syntax: '%s/%s'",
clispec_dir, dp[i].d_name);
if (clispec_load_file(h, dp[i].d_name, clispec_dir, ptall, modes) < 0)
goto done;
@@ -555,7 +555,7 @@ clicon_parse(clixon_handle h,
if (cliread_parse(ch, cmd, pt, &match_obj, &cvv, result, &reason) < 0)
goto done;
/* Debug command and result code */
- clixon_debug(CLIXON_DBG_CLIENT, "result:%d command: \"%s\"", *result, cmd);
+ clixon_debug(CLIXON_DBG_CLI, "result:%d command: \"%s\"", *result, cmd);
switch (*result) {
case CG_EOF: /* eof */
case CG_ERROR:
diff --git a/apps/netconf/netconf_main.c b/apps/netconf/netconf_main.c
index f329261e..d617c1b2 100644
--- a/apps/netconf/netconf_main.c
+++ b/apps/netconf/netconf_main.c
@@ -159,7 +159,7 @@ netconf_hello_msg(clixon_handle h,
int foundbase_11 = 0;
char *body;
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_NETCONF, "");
_netconf_hello_nr++;
if (xml_find_type(xn, NULL, "session-id", CX_ELMNT) != NULL) {
clixon_err(OE_XML, errno, "Server received hello with session-id from client, terminating (see RFC 6241 Sec 8.1");
@@ -179,12 +179,12 @@ netconf_hello_msg(clixon_handle h,
* event any parameters are encoded at the end of the URI string. */
if (strncmp(body, NETCONF_BASE_CAPABILITY_1_0, strlen(NETCONF_BASE_CAPABILITY_1_0)) == 0){ /* RFC 4741 */
foundbase_10++;
- clixon_debug(CLIXON_DBG_CLIENT, "foundbase10");
+ clixon_debug(CLIXON_DBG_NETCONF, "foundbase10");
}
else if (strncmp(body, NETCONF_BASE_CAPABILITY_1_1, strlen(NETCONF_BASE_CAPABILITY_1_1)) == 0 &&
clicon_option_int(h, "CLICON_NETCONF_BASE_CAPABILITY") > 0){ /* RFC 6241 */
foundbase_11++;
- clixon_debug(CLIXON_DBG_CLIENT, "foundbase11");
+ clixon_debug(CLIXON_DBG_NETCONF, "foundbase11");
clicon_data_int_set(h, NETCONF_FRAMING_TYPE, NETCONF_SSH_CHUNKED); /* enable chunked enc */
}
}
@@ -334,8 +334,8 @@ netconf_input_packet(clixon_handle h,
cxobj *xret = NULL;
netconf_framing_type framing;
- clixon_debug(CLIXON_DBG_CLIENT, "");
- clixon_debug_xml(CLIXON_DBG_CLIENT, xreq, "");
+ clixon_debug(CLIXON_DBG_NETCONF, "");
+ clixon_debug_xml(CLIXON_DBG_NETCONF, xreq, "");
rpcname = xml_name(xreq);
rpcprefix = xml_prefix(xreq);
framing = clicon_data_int_get(h, NETCONF_FRAMING_TYPE);
@@ -469,7 +469,7 @@ netconf_input_cb(int s,
&eom) < 0)
goto done;
if (eom == 0){ /* frame not complete */
- clixon_debug(CLIXON_DBG_CLIENT | CLIXON_DBG_DETAIL, "frame: %lu", cbuf_len(cbmsg));
+ clixon_debug(CLIXON_DBG_NETCONF | CLIXON_DBG_DETAIL, "frame: %lu", cbuf_len(cbmsg));
/* Extra data to read, save data and continue on next round */
if (clicon_hash_add(cdat, NETCONF_FRAME_MSG, &cbmsg, sizeof(cbmsg)) == NULL)
goto done;
@@ -511,7 +511,7 @@ netconf_input_cb(int s,
}
}
if (eof){ /* socket closed / read returns 0 */
- clixon_debug(CLIXON_DBG_CLIENT, "len==0, closing");
+ clixon_debug(CLIXON_DBG_NETCONF, "len==0, closing");
clixon_event_unreg_fd(s, netconf_input_cb);
close(s);
clixon_exit_set(1);
@@ -637,7 +637,7 @@ usage(clixon_handle h,
"where options are\n"
"\t-h\t\tHelp\n"
"\t-V \t\tPrint version and exit\n"
- "\t-D \tDebug level\n"
+ "\t-D \tDebug level (see available levels below)\n"
"\t-f \tConfiguration file (mandatory)\n"
"\t-E \tExtra configuration file directory\n"
"\t-l > \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n"
@@ -657,6 +657,9 @@ usage(clixon_handle h,
argv0,
clicon_netconf_dir(h)
);
+ fprintf(stderr, "Debug keys: ");
+ clixon_debug_key_dump(stderr);
+ fprintf(stderr, "\n");
exit(0);
}
@@ -709,10 +712,16 @@ main(int argc,
cligen_output(stdout, "Clixon version %s\n", CLIXON_VERSION_STRING);
print_version++; /* plugins may also print versions w ca-version callback */
break;
- case 'D' : /* debug */
- if (sscanf(optarg, "%d", &dbg) != 1)
+ case 'D' : { /* debug */
+ int d = 0;
+ /* 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;
+ }
case 'f': /* override config file */
if (!strlen(optarg))
usage(h, argv[0]);
diff --git a/apps/netconf/netconf_rpc.c b/apps/netconf/netconf_rpc.c
index 44ef226e..806874ec 100644
--- a/apps/netconf/netconf_rpc.c
+++ b/apps/netconf/netconf_rpc.c
@@ -459,7 +459,7 @@ netconf_notification_cb(int s,
int ret;
cxobj *xerr = NULL;
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_NETCONF, "");
/* get msg (this is the reason this function is called) */
if (clicon_msg_rcv(s, NULL, 0, &reply, &eof) < 0)
goto done;
@@ -504,7 +504,7 @@ netconf_notification_cb(int s,
ok:
retval = 0;
done:
- clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval);
+ clixon_debug(CLIXON_DBG_NETCONF, "retval:%d", retval);
if (cb)
cbuf_free(cb);
if (nsc)
diff --git a/apps/restconf/clixon_http_data.c b/apps/restconf/clixon_http_data.c
index 426c5946..6db5f676 100644
--- a/apps/restconf/clixon_http_data.c
+++ b/apps/restconf/clixon_http_data.c
@@ -131,7 +131,7 @@ api_http_data_err(clixon_handle h,
int retval = -1;
cbuf *cb = NULL;
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_RESTCONF, "");
if ((cb = cbuf_new()) == NULL){
clixon_err(OE_UNIX, errno, "cbuf_new");
goto done;
@@ -153,7 +153,7 @@ api_http_data_err(clixon_handle h,
// ok:
retval = 0;
done:
- clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval);
+ clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
if (cb)
cbuf_free(cb);
return retval;
@@ -192,7 +192,7 @@ http_data_check_file_path(clixon_handle h,
goto done;
}
p = cbuf_get(cbpath);
- clixon_debug(CLIXON_DBG_CLIENT, "%s", p);
+ clixon_debug(CLIXON_DBG_RESTCONF, "%s", p);
if (strncmp(prefix, p, strlen(prefix)) != 0){
clixon_err(OE_UNIX, EINVAL, "prefix is not prefix of cbpath");
goto done;
@@ -202,31 +202,31 @@ http_data_check_file_path(clixon_handle h,
p[i] = '\0';
/* Ensure not soft link */
if (lstat(p, &fstat) < 0){
- clixon_debug(CLIXON_DBG_CLIENT, "Error lstat(%s):%s", p, strerror(errno));
+ clixon_debug(CLIXON_DBG_RESTCONF, "Error lstat(%s):%s", p, strerror(errno));
code = 404;
goto invalid;
}
if (!S_ISDIR(fstat.st_mode)){
- clixon_debug(CLIXON_DBG_CLIENT, "Error lstat(%s): Not dir", p);
+ clixon_debug(CLIXON_DBG_RESTCONF, "Error lstat(%s): Not dir", p);
code = 403;
goto invalid;
}
p[i] = '/';
}
else if (p[i] == '~'){
- clixon_debug(CLIXON_DBG_CLIENT, "Error lstat(%s): ~ not allowed in file path", p);
+ clixon_debug(CLIXON_DBG_RESTCONF, "Error lstat(%s): ~ not allowed in file path", p);
code = 403;
goto invalid;
}
else if (p[i] == '.' && i>strlen(prefix) && p[i-1] == '.'){
- clixon_debug(CLIXON_DBG_CLIENT, "Error lstat(%s): .. not allowed in file path", p);
+ clixon_debug(CLIXON_DBG_RESTCONF, "Error lstat(%s): .. not allowed in file path", p);
code = 403;
goto invalid;
}
}
/* Resulting file (ensure not soft link) */
if (lstat(p, &fstat) < 0){
- clixon_debug(CLIXON_DBG_CLIENT, "Error lstat(%s):%s", p, strerror(errno));
+ clixon_debug(CLIXON_DBG_RESTCONF, "Error lstat(%s):%s", p, strerror(errno));
code = 404;
goto invalid;
}
@@ -235,22 +235,22 @@ http_data_check_file_path(clixon_handle h,
if (S_ISDIR(fstat.st_mode)){
cprintf(cbpath, "/%s", HTTP_DATA_INTERNAL_REDIRECT);
p = cbuf_get(cbpath);
- clixon_debug(CLIXON_DBG_CLIENT, "internal redirect: %s", p);
+ clixon_debug(CLIXON_DBG_RESTCONF, "internal redirect: %s", p);
if (lstat(p, &fstat) < 0){
- clixon_debug(CLIXON_DBG_CLIENT, "Error lstat(%s):%s", p, strerror(errno));
+ clixon_debug(CLIXON_DBG_RESTCONF, "Error lstat(%s):%s", p, strerror(errno));
code = 404;
goto invalid;
}
}
#endif
if (!S_ISREG(fstat.st_mode)){
- clixon_debug(CLIXON_DBG_CLIENT, "Error lstat(%s): Not regular file", p);
+ clixon_debug(CLIXON_DBG_RESTCONF, "Error lstat(%s): Not regular file", p);
code = 403;
goto invalid;
}
*fsz = fstat.st_size;
if ((f = fopen(p, "rb")) == NULL){
- clixon_debug(CLIXON_DBG_CLIENT, "Error fopen(%s) %s", p, strerror(errno));
+ clixon_debug(CLIXON_DBG_RESTCONF, "Error fopen(%s) %s", p, strerror(errno));
code = 403;
goto invalid;
}
@@ -296,7 +296,7 @@ api_http_data_file(clixon_handle h,
char *buf = NULL;
size_t sz;
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_RESTCONF, "");
if ((cbfile = cbuf_new()) == NULL){
clixon_err(OE_UNIX, errno, "cbuf_new");
goto done;
@@ -309,7 +309,7 @@ api_http_data_file(clixon_handle h,
cprintf(cbfile, "%s", www_data_root);
if (pathname){
if (strlen(pathname) && pathname[0] != '/'){
- clixon_debug(CLIXON_DBG_CLIENT, "Error fopen(%s) pathname not prefixed with /",
+ clixon_debug(CLIXON_DBG_RESTCONF, "Error fopen(%s) pathname not prefixed with /",
pathname);
if (api_http_data_err(h, req, 404) < 0)
goto done;
@@ -338,7 +338,7 @@ api_http_data_file(clixon_handle h,
fsize = ftell(f);
/* Extra sanity check, had some problems with wrong file types */
if (fsz != fsize){
- clixon_debug(CLIXON_DBG_CLIENT, "Error file %s size mismatch sz:%zu vs %li",
+ clixon_debug(CLIXON_DBG_RESTCONF, "Error file %s size mismatch sz:%zu vs %li",
filename, (size_t)fsz, fsize);
if (api_http_data_err(h, req, 500) < 0) /* Internal error? */
goto done;
@@ -362,7 +362,7 @@ api_http_data_file(clixon_handle h,
}
sz = (size_t)ret;
if (sz != 1){
- clixon_debug(CLIXON_DBG_CLIENT, "Error fread(%s) sz:%zu", filename, sz);
+ clixon_debug(CLIXON_DBG_RESTCONF, "Error fread(%s) sz:%zu", filename, sz);
if (api_http_data_err(h, req, 500) < 0) /* Internal error? */
goto done;
goto ok;
@@ -376,7 +376,7 @@ api_http_data_file(clixon_handle h,
if (restconf_reply_send(req, 200, cbdata, head) < 0)
goto done;
cbdata = NULL; /* consumed by reply-send */
- clixon_debug(CLIXON_DBG_CLIENT, "Read %s OK", filename);
+ clixon_debug(CLIXON_DBG_RESTCONF, "Read %s OK", filename);
ok:
retval = 0;
done:
@@ -423,7 +423,7 @@ api_http_data(clixon_handle h,
cbuf *indata = NULL;
char *path = NULL;
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_RESTCONF, "");
if (req == NULL){
errno = EINVAL;
goto done;
@@ -498,6 +498,6 @@ api_http_data(clixon_handle h,
done:
if (path)
free(path);
- clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval);
+ clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
return retval;
}
diff --git a/apps/restconf/restconf_api_native.c b/apps/restconf/restconf_api_native.c
index bed1d6a7..13c3cd30 100644
--- a/apps/restconf/restconf_api_native.c
+++ b/apps/restconf/restconf_api_native.c
@@ -86,7 +86,7 @@ restconf_reply_header(void *req0,
char *value = NULL;
va_list ap;
- clixon_debug(CLIXON_DBG_CLIENT, "%s", name);
+ clixon_debug(CLIXON_DBG_RESTCONF, "%s", name);
if (sd == NULL || name == NULL || vfmt == NULL){
clixon_err(OE_CFG, EINVAL, "sd, name or value is NULL");
goto done;
@@ -142,7 +142,7 @@ restconf_reply_send(void *req0,
int retval = -1;
restconf_stream_data *sd = (restconf_stream_data *)req0;
- clixon_debug(CLIXON_DBG_CLIENT, "code:%d", code);
+ clixon_debug(CLIXON_DBG_RESTCONF, "code:%d", code);
if (sd == NULL){
clixon_err(OE_CFG, EINVAL, "sd is NULL");
goto done;
diff --git a/apps/restconf/restconf_err.c b/apps/restconf/restconf_err.c
index 15da4d18..ebf0b0f0 100644
--- a/apps/restconf/restconf_err.c
+++ b/apps/restconf/restconf_err.c
@@ -218,7 +218,7 @@ api_return_err(clixon_handle h,
cxobj *xmsg;
char *mb;
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_RESTCONF, "");
if ((cb = cbuf_new()) == NULL){
clixon_err(OE_UNIX, errno, "cbuf_new");
goto done;
@@ -249,7 +249,7 @@ api_return_err(clixon_handle h,
}
}
#if 1
- clixon_debug_xml(CLIXON_DBG_CLIENT, xerr, "Send error:");
+ clixon_debug_xml(CLIXON_DBG_RESTCONF, xerr, "Send error:");
#endif
if (xml_name_set(xerr, "error") < 0)
goto done;
@@ -286,7 +286,7 @@ api_return_err(clixon_handle h,
case YANG_DATA_XML:
case YANG_PATCH_XML:
case YANG_PAGINATION_XML:
- clixon_debug(CLIXON_DBG_CLIENT, "code:%d", code);
+ clixon_debug(CLIXON_DBG_RESTCONF, "code:%d", code);
if (pretty){
cprintf(cb, " \n");
if (clixon_xml2cbuf(cb, xerr, 2, pretty, NULL, -1, 0) < 0)
@@ -302,7 +302,7 @@ api_return_err(clixon_handle h,
break;
case YANG_DATA_JSON:
case YANG_PATCH_JSON:
- clixon_debug(CLIXON_DBG_CLIENT, "code:%d", code);
+ clixon_debug(CLIXON_DBG_RESTCONF, "code:%d", code);
if (pretty){
cprintf(cb, "{\n\"ietf-restconf:errors\" : ");
if (clixon_json2cbuf(cb, xerr, pretty, 0, 0) < 0)
@@ -329,7 +329,7 @@ api_return_err(clixon_handle h,
// ok:
retval = 0;
done:
- clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval);
+ clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
if (cb)
cbuf_free(cb);
if (cberr)
diff --git a/apps/restconf/restconf_handle.c b/apps/restconf/restconf_handle.c
index 7d97b234..9afe8f81 100644
--- a/apps/restconf/restconf_handle.c
+++ b/apps/restconf/restconf_handle.c
@@ -160,7 +160,7 @@ restconf_param_set(clixon_handle h,
{
struct restconf_handle *rh = handle(h);
- clixon_debug(CLIXON_DBG_CLIENT, "%s=%s", param, val);
+ clixon_debug(CLIXON_DBG_RESTCONF, "%s=%s", param, val);
if (rh->rh_params == NULL)
if ((rh->rh_params = clicon_hash_init()) == NULL)
return -1;
diff --git a/apps/restconf/restconf_http1.c b/apps/restconf/restconf_http1.c
index 47ac9730..1d11902b 100644
--- a/apps/restconf/restconf_http1.c
+++ b/apps/restconf/restconf_http1.c
@@ -90,7 +90,7 @@ _http1_parse(clixon_handle h,
clixon_http1_yacc hy = {0,};
int ret;
- clixon_debug(CLIXON_DBG_CLIENT, "\n%s", str);
+ clixon_debug(CLIXON_DBG_RESTCONF, "\n%s", str);
if (strlen(str) == 0)
goto ok;
hy.hy_parse_string = str;
@@ -119,7 +119,7 @@ _http1_parse(clixon_handle h,
ok:
retval = 0;
done:
- clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval);
+ clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
return retval;
}
@@ -147,7 +147,7 @@ clixon_http1_parse_file(clixon_handle h,
int len = 0;
int oldbuflen;
- clixon_debug(CLIXON_DBG_CLIENT, "%s", filename);
+ clixon_debug(CLIXON_DBG_RESTCONF, "%s", filename);
if (f == NULL){
clixon_err(OE_RESTCONF, EINVAL, "f is NULL");
goto done;
@@ -302,7 +302,7 @@ restconf_http1_reply(restconf_conn *rc,
int retval = -1;
cg_var *cv;
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_RESTCONF, "");
/* If body, add a content-length header
* A server MUST NOT send a Content-Length header field in any response
* with a status code of 1xx (Informational) or 204 (No Content). A
@@ -365,7 +365,7 @@ restconf_http1_path_root(clixon_handle h,
int ret;
#endif
- clixon_debug(CLIXON_DBG_CLIENT, "------------");
+ clixon_debug(CLIXON_DBG_RESTCONF, "------------");
pretty = restconf_pretty_get(h);
if ((sd = restconf_stream_find(rc, 0)) == NULL){
clixon_err(OE_RESTCONF, EINVAL, "No stream_data");
@@ -463,7 +463,7 @@ restconf_http1_path_root(clixon_handle h,
goto done;
retval = 0;
done:
- clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval);
+ clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
if (subject)
free(subject);
if (xerr)
diff --git a/apps/restconf/restconf_lib.c b/apps/restconf/restconf_lib.c
index e83852f9..18ea2dcb 100644
--- a/apps/restconf/restconf_lib.c
+++ b/apps/restconf/restconf_lib.c
@@ -360,7 +360,7 @@ restconf_terminate(clixon_handle h)
cxobj *x;
int fs; /* fgcx socket */
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_RESTCONF, "");
if ((fs = clicon_socket_get(h)) != -1)
close(fs);
/* Delete all plugins, and RPC callbacks */
@@ -378,7 +378,7 @@ restconf_terminate(clixon_handle h)
xpath_optimize_exit();
restconf_handle_exit(h);
clixon_err_exit();
- clixon_debug(CLIXON_DBG_CLIENT, "pid:%u done", getpid());
+ clixon_debug(CLIXON_DBG_RESTCONF, "pid:%u done", getpid());
clixon_log_exit(); /* Must be after last clixon_debug */
return 0;
}
@@ -524,7 +524,7 @@ restconf_main_extension_cb(clixon_handle h,
extname = yang_argument_get(yext);
if (strcmp(modname, "ietf-restconf") != 0 || strcmp(extname, "yang-data") != 0)
goto ok;
- clixon_debug(CLIXON_DBG_CLIENT, "Enabled extension:%s:%s", modname, extname);
+ clixon_debug(CLIXON_DBG_RESTCONF, "Enabled extension:%s:%s", modname, extname);
if ((yc = yang_find(ys, 0, NULL)) == NULL)
goto ok;
if ((yn = ys_dup(yc)) == NULL)
@@ -584,7 +584,7 @@ restconf_drop_privileges(clixon_handle h)
char *user;
enum priv_mode_t priv_mode = PM_NONE;
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_RESTCONF, "");
/* Sanity check: backend group exists */
if ((group = clicon_sock_group(h)) == NULL){
clixon_err(OE_FATAL, 0, "clicon_sock_group option not set");
@@ -639,7 +639,7 @@ restconf_drop_privileges(clixon_handle h)
case PM_NONE:
break; /* catched above */
}
- clixon_debug(CLIXON_DBG_CLIENT, "dropped privileges from root to %s(%d)",
+ clixon_debug(CLIXON_DBG_RESTCONF, "dropped privileges from root to %s(%d)",
user, newuid);
ok:
retval = 0;
@@ -673,7 +673,7 @@ restconf_authentication_cb(clixon_handle h,
char *anonymous = NULL;
auth_type = restconf_auth_type_get(h);
- clixon_debug(CLIXON_DBG_CLIENT, "auth-type:%s", clixon_auth_type_int2str(auth_type));
+ clixon_debug(CLIXON_DBG_RESTCONF, "auth-type:%s", clixon_auth_type_int2str(auth_type));
ret = 0;
authenticated = 0;
/* ret: -1 Error, 0: Ignore/not handled, 1: OK see authenticated parameter */
@@ -725,7 +725,7 @@ restconf_authentication_cb(clixon_handle h,
/* If set but no user, set a dummy user */
retval = 1;
done:
- clixon_debug(CLIXON_DBG_CLIENT, "retval:%d authenticated:%d user:%s",
+ clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d authenticated:%d user:%s",
retval, authenticated, clicon_username_get(h));
if (username)
free(username);
@@ -768,7 +768,7 @@ restconf_config_init(clixon_handle h,
if ((x = xpath_first(xrestconf, nsc, "enable")) != NULL &&
(enable = xml_body(x)) != NULL){
if (strcmp(enable, "false") == 0){
- clixon_debug(CLIXON_DBG_CLIENT, "restconf disabled");
+ clixon_debug(CLIXON_DBG_RESTCONF, "restconf disabled");
goto disable;
}
}
@@ -848,7 +848,7 @@ restconf_socket_init(const char *netns0,
size_t sa_len;
const char *netns;
- clixon_debug(CLIXON_DBG_CLIENT, "%s %s %s %hu", netns0, addrtype, addrstr, port);
+ clixon_debug(CLIXON_DBG_RESTCONF, "%s %s %s %hu", netns0, addrtype, addrstr, port);
/* netns default -> NULL */
if (netns0 != NULL && strcmp(netns0, RESTCONF_NETNS_DEFAULT)==0)
netns = NULL;
@@ -858,10 +858,10 @@ restconf_socket_init(const char *netns0,
goto done;
if (clixon_netns_socket(netns, sa, sa_len, backlog, flags, addrstr, ss) < 0)
goto done;
- clixon_debug(CLIXON_DBG_CLIENT, "ss=%d", *ss);
+ clixon_debug(CLIXON_DBG_RESTCONF, "ss=%d", *ss);
retval = 0;
done:
- clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval);
+ clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
return retval;
}
diff --git a/apps/restconf/restconf_main_fcgi.c b/apps/restconf/restconf_main_fcgi.c
index d299cb92..e7e69b40 100644
--- a/apps/restconf/restconf_main_fcgi.c
+++ b/apps/restconf/restconf_main_fcgi.c
@@ -107,7 +107,7 @@ fcgi_params_set(clixon_handle h,
char *param = NULL;
char *val = NULL;
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_RESTCONF, "");
for (i = 0; envp[i] != NULL; i++){ /* on the form = */
if (clixon_strsplit(envp[i], '=', ¶m, &val) < 0)
goto done;
@@ -124,7 +124,7 @@ fcgi_params_set(clixon_handle h,
}
retval = 0;
done:
- clixon_debug(CLIXON_DBG_CLIENT, "retval:%d", retval);
+ clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
return retval;
}
@@ -147,7 +147,7 @@ restconf_main_config(clixon_handle h,
/* 1. try inline configure option */
if (inline_config != NULL && strlen(inline_config)){
- clixon_debug(CLIXON_DBG_CLIENT, "restconf_main_fcgi using restconf inline config");
+ clixon_debug(CLIXON_DBG_RESTCONF, "restconf_main_fcgi using restconf inline config");
if ((ret = clixon_xml_parse_string(inline_config, YB_MODULE, yspec, &xrestconf, &xerr)) < 0)
goto done;
if (ret == 0){
@@ -228,12 +228,12 @@ restconf_sig_term(int arg)
{
static int i=0;
- clixon_debug(CLIXON_DBG_CLIENT, "");
+ clixon_debug(CLIXON_DBG_RESTCONF, "");
if (i++ == 0)
clixon_log(NULL, LOG_NOTICE, "%s: %s: pid: %u Signal %d",
__PROGRAM__, __FUNCTION__, getpid(), arg);
else{
- clixon_debug(CLIXON_DBG_CLIENT, "done");
+ clixon_debug(CLIXON_DBG_RESTCONF, "done");
exit(-1);
}
@@ -272,7 +272,7 @@ usage(clixon_handle h,
"where options are\n"
"\t-h \t\t Help\n"
"\t-V \t\tPrint version and exit\n"
- "\t-D \t Debug level\n"
+ "\t-D \tDebug level (see available levels below)\n"
"\t-f \t Configuration file (mandatory)\n"
"\t-E \t Extra configuration file directory\n"
"\t-l > \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n"
@@ -288,6 +288,9 @@ usage(clixon_handle h,
"\t-o \"