From ff171afd65b65d8ac0db946d8fde7a16c8a6d09b Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Sat, 17 Feb 2024 22:16:56 +0100 Subject: [PATCH] Added debug level INIT --- apps/backend/backend_main.c | 2 +- apps/cli/cli_generate.c | 6 ++--- apps/cli/cli_main.c | 2 +- apps/netconf/netconf_main.c | 2 +- apps/restconf/restconf_main_fcgi.c | 2 +- apps/restconf/restconf_main_native.c | 4 +-- apps/snmp/snmp_main.c | 2 +- example/main/example_backend.c | 2 +- example/main/example_backend_nacm.c | 2 +- lib/clixon/clixon_debug.h | 39 +++++++++++++++------------- lib/src/clixon_debug.c | 1 + lib/src/clixon_options.c | 11 ++++---- lib/src/clixon_plugin.c | 10 +++---- lib/src/clixon_sig.c | 2 +- 14 files changed, 45 insertions(+), 42 deletions(-) diff --git a/apps/backend/backend_main.c b/apps/backend/backend_main.c index cd034bf2..7671a7b4 100644 --- a/apps/backend/backend_main.c +++ b/apps/backend/backend_main.c @@ -1050,7 +1050,7 @@ main(int argc, goto ok; /* Debug dump of config options */ - clicon_option_dump(h, 1); + clicon_option_dump(h, CLIXON_DBG_INIT); /* Daemonize and initiate logging. Note error is initiated here to make daemonized errors OK. Before this stage, errors are logged on stderr diff --git a/apps/cli/cli_generate.c b/apps/cli/cli_generate.c index 9ef56b59..b91d4bcb 100644 --- a/apps/cli/cli_generate.c +++ b/apps/cli/cli_generate.c @@ -983,7 +983,6 @@ yang2cli_container(clixon_handle h, cprintf(cb, ", hide"); } cprintf(cb, ", act-container;{\n"); - } /* Is schema mount-point? */ if (clicon_option_bool(h, "CLICON_YANG_SCHEMA_MOUNT")){ @@ -1315,8 +1314,9 @@ yang2cli_stmt(clixon_handle h, goto done; break; case Y_USES: - if (grouping_treeref && !cornercase && yang2cli_uses(h, ys, level, cb) < 0) - goto done; + if (grouping_treeref && !cornercase) + if (yang2cli_uses(h, ys, level, cb) < 0) + goto done; break; case Y_CASE: case Y_SUBMODULE: diff --git a/apps/cli/cli_main.c b/apps/cli/cli_main.c index 69380f43..69a29e17 100644 --- a/apps/cli/cli_main.c +++ b/apps/cli/cli_main.c @@ -894,7 +894,7 @@ main(int argc, goto done; } /* Debug dump of config options */ - clicon_option_dump(h, 1); + clicon_option_dump(h, CLIXON_DBG_INIT); cligen_line_scrolling_set(cli_cligen(h), clicon_option_int(h,"CLICON_CLI_LINESCROLLING")); /* Start CLI history and load from file */ diff --git a/apps/netconf/netconf_main.c b/apps/netconf/netconf_main.c index c85a586c..8f0e13bc 100644 --- a/apps/netconf/netconf_main.c +++ b/apps/netconf/netconf_main.c @@ -923,7 +923,7 @@ main(int argc, goto ok; } /* Debug dump of config options */ - clicon_option_dump(h, 1); + clicon_option_dump(h, CLIXON_DBG_INIT); /* Send hello request to backend to get session-id back * This is done once at the beginning of the session and then this is diff --git a/apps/restconf/restconf_main_fcgi.c b/apps/restconf/restconf_main_fcgi.c index 5f47629e..69dd409b 100644 --- a/apps/restconf/restconf_main_fcgi.c +++ b/apps/restconf/restconf_main_fcgi.c @@ -574,7 +574,7 @@ main(int argc, goto ok; } /* Dump configuration options on debug */ - clicon_option_dump(h, 1); + clicon_option_dump(h, CLIXON_DBG_INIT); /* Call start function in all plugins before we go interactive */ if (clixon_plugin_start_all(h) < 0) diff --git a/apps/restconf/restconf_main_native.c b/apps/restconf/restconf_main_native.c index 9c7d1b6f..b479461c 100644 --- a/apps/restconf/restconf_main_native.c +++ b/apps/restconf/restconf_main_native.c @@ -839,7 +839,7 @@ restconf_openssl_init(clixon_handle h, /* If debug was enabled here from config and not initially, * print clixn options and loaded yang files */ - clicon_option_dump(h, 1); + clicon_option_dump(h, CLIXON_DBG_INIT); } if ((x = xpath_first(xrestconf, nsc, "enable-core-dump")) != NULL) { /* core dump is enabled on RESTCONF process */ @@ -1318,7 +1318,7 @@ main(int argc, goto ok; } /* Dump configuration options on debug */ - clicon_option_dump(h, 1); + clicon_option_dump(h, CLIXON_DBG_INIT); /* Initialize plugin module by creating a handle holding plugin and callback lists */ if (clixon_plugin_module_init(h) < 0) diff --git a/apps/snmp/snmp_main.c b/apps/snmp/snmp_main.c index b9d7ff69..61874ddd 100644 --- a/apps/snmp/snmp_main.c +++ b/apps/snmp/snmp_main.c @@ -553,7 +553,7 @@ main(int argc, goto done; goto ok; } - clicon_option_dump(h, 1); + clicon_option_dump(h, CLIXON_DBG_INIT); /* Send hello request to backend to get session-id back * This is done once at the beginning of the session and then this is diff --git a/example/main/example_backend.c b/example/main/example_backend.c index feb2e116..f0327960 100644 --- a/example/main/example_backend.c +++ b/example/main/example_backend.c @@ -1432,7 +1432,7 @@ clixon_plugin_init(clixon_handle h) char **argv; int c; - clixon_debug(CLIXON_DBG_DEFAULT, "backend"); + clixon_debug(CLIXON_DBG_INIT, "backend"); /* Get user command-line options (after --) */ if (clicon_argv_get(h, &argc, &argv) < 0) diff --git a/example/main/example_backend_nacm.c b/example/main/example_backend_nacm.c index 04fd9017..8258b372 100644 --- a/example/main/example_backend_nacm.c +++ b/example/main/example_backend_nacm.c @@ -241,7 +241,7 @@ clixon_plugin_init(clixon_handle h) char **argv; int c; - clixon_debug(CLIXON_DBG_DEFAULT, "backend nacm"); + clixon_debug(CLIXON_DBG_INIT, "backend nacm"); /* Get user command-line options (after --) */ if (clicon_argv_get(h, &argc, &argv) < 0) goto done; diff --git a/lib/clixon/clixon_debug.h b/lib/clixon/clixon_debug.h index 766cc6a0..ad3ee35f 100644 --- a/lib/clixon/clixon_debug.h +++ b/lib/clixon/clixon_debug.h @@ -60,24 +60,27 @@ /* Subject area */ #define CLIXON_DBG_DEFAULT 0x00000001 /* Default logs */ #define CLIXON_DBG_MSG 0x00000002 /* In/out messages */ -#define CLIXON_DBG_XML 0x00000004 /* XML processing */ -#define CLIXON_DBG_XPATH 0x00000008 /* XPath processing */ -#define CLIXON_DBG_YANG 0x00000010 /* YANG processing */ -#define CLIXON_DBG_BACKEND 0x00000020 /* Backend-specific */ -#define CLIXON_DBG_CLI 0x00000040 /* CLI frontend */ -#define CLIXON_DBG_NETCONF 0x00000080 /* NETCONF frontend */ -#define CLIXON_DBG_RESTCONF 0x00000100 /* RESTCONF frontend */ -#define CLIXON_DBG_SNMP 0x00000200 /* SNMP frontend */ -#define CLIXON_DBG_NACM 0x00000400 /* NACM processing */ -#define CLIXON_DBG_PROC 0x00000800 /* Process handling */ -#define CLIXON_DBG_DATASTORE 0x00001000 /* Datastore management */ -#define CLIXON_DBG_EVENT 0x00002000 /* Event processing */ -#define CLIXON_DBG_RPC 0x00004000 /* RPC handling */ -#define CLIXON_DBG_STREAM 0x00008000 /* Notification streams */ -#define CLIXON_DBG_APP 0x00010000 /* External application */ -#define CLIXON_DBG_APP2 0x00020000 /* External application 2 */ -#define CLIXON_DBG_APP3 0x00040000 /* External application 3 */ -#define CLIXON_DBG_SMASK 0x0003ffff /* Subject mask */ +#define CLIXON_DBG_INIT 0x00000004 /* Initialization */ +#define CLIXON_DBG_XML 0x00000008 /* XML processing */ +#define CLIXON_DBG_XPATH 0x00000010 /* XPath processing */ +#define CLIXON_DBG_YANG 0x00000020 /* YANG processing */ +#define CLIXON_DBG_BACKEND 0x00000040 /* Backend-specific */ +#define CLIXON_DBG_CLI 0x00000080 /* CLI frontend */ +#define CLIXON_DBG_NETCONF 0x00000100 /* NETCONF frontend */ +#define CLIXON_DBG_RESTCONF 0x00000200 /* RESTCONF frontend */ +#define CLIXON_DBG_SNMP 0x00000400 /* SNMP frontend */ +#define CLIXON_DBG_NACM 0x00000800 /* NACM processing */ +#define CLIXON_DBG_PROC 0x00001000 /* Process handling */ +#define CLIXON_DBG_DATASTORE 0x00002000 /* Datastore management */ +#define CLIXON_DBG_EVENT 0x00004000 /* Event processing */ +#define CLIXON_DBG_RPC 0x00008000 /* RPC handling */ +#define CLIXON_DBG_STREAM 0x00010000 /* Notification streams */ + +/* External applications */ +#define CLIXON_DBG_APP 0x00100000 /* External application */ +#define CLIXON_DBG_APP2 0x00200000 /* External application 2 */ +#define CLIXON_DBG_APP3 0x00400000 /* External application 3 */ +#define CLIXON_DBG_SMASK 0x00ffffff /* Subject mask */ /* * Macros diff --git a/lib/src/clixon_debug.c b/lib/src/clixon_debug.c index 3bc00d7a..c3235eeb 100644 --- a/lib/src/clixon_debug.c +++ b/lib/src/clixon_debug.c @@ -86,6 +86,7 @@ static clixon_handle _debug_clixon_h = NULL; static const map_str2int dbgmap[] = { {"default", CLIXON_DBG_DEFAULT}, {"msg", CLIXON_DBG_MSG}, + {"init", CLIXON_DBG_INIT}, {"xml", CLIXON_DBG_XML}, {"xpath", CLIXON_DBG_XPATH}, {"yang", CLIXON_DBG_YANG}, diff --git a/lib/src/clixon_options.c b/lib/src/clixon_options.c index 72410d58..4e8d8e6f 100644 --- a/lib/src/clixon_options.c +++ b/lib/src/clixon_options.c @@ -259,7 +259,7 @@ parse_configfile_one(clixon_handle h, clixon_err(OE_UNIX, errno, "open configure file: %s", filename); return -1; } - clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, "Reading config file %s", filename); + clixon_debug(CLIXON_DBG_INIT, "Reading config file %s", filename); if ((ret = clixon_xml_parse_file(fp, yspec?YB_MODULE:YB_NONE, yspec, &xt, &xerr)) < 0) goto done; if (ret == 0){ @@ -284,7 +284,7 @@ parse_configfile_one(clixon_handle h, xt = NULL; retval = 0; done: - clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, "Done w/ config file %s retval:%d", filename, retval); + clixon_debug(CLIXON_DBG_INIT | CLIXON_DBG_DETAIL, "Done w/ config file %s retval:%d", filename, retval); if (xt) xml_free(xt); if (fp) @@ -406,8 +406,7 @@ parse_configfile(clixon_handle h, clixon_err(OE_UNIX, 0, "%s is not a regular file", filename); goto done; } - - clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, "Reading config file %s", filename); + clixon_debug(CLIXON_DBG_INIT, "Reading config file %s", filename); /* Parse main config file */ if (parse_configfile_one(h, filename, yspec, &xt) < 0) goto done; @@ -495,7 +494,7 @@ parse_configfile(clixon_handle h, *xconfig = xt; xt = NULL; done: - clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, "Done w/ config file %s retval:%d", filename, retval); + clixon_debug(CLIXON_DBG_INIT | CLIXON_DBG_DETAIL, "Done w/ config file %s retval:%d", filename, retval); if (dp) free(dp); if (nsc) @@ -599,7 +598,7 @@ clicon_options_main(clixon_handle h) configfile = clicon_hash_value(copt, "CLICON_CONFIGFILE", NULL); if (strlen(configfile) == 0) configfile = clicon_hash_value(copt, "CLICON_CONFIGFILE", NULL); - clixon_debug(CLIXON_DBG_DEFAULT, "CLICON_CONFIGFILE=%s", configfile); + clixon_debug(CLIXON_DBG_INIT, "CLICON_CONFIGFILE=%s", configfile); /* File must end with .xml */ if ((suffix = rindex(configfile, '.')) != NULL){ suffix++; diff --git a/lib/src/clixon_plugin.c b/lib/src/clixon_plugin.c index 49717a41..a2460060 100644 --- a/lib/src/clixon_plugin.c +++ b/lib/src/clixon_plugin.c @@ -328,7 +328,7 @@ plugin_load_one(clixon_handle h, char *p; void *wh = NULL; - clixon_debug(CLIXON_DBG_DEFAULT, "file:%s function:%s", file, function); + clixon_debug(CLIXON_DBG_INIT, "file:%s function:%s", file, function); dlerror(); /* Clear any existing error */ if ((handle = dlopen(file, dlflags)) == NULL) { error = (char*)dlerror(); @@ -383,7 +383,7 @@ plugin_load_one(clixon_handle h, } retval = 1; done: - clixon_debug(CLIXON_DBG_DEFAULT, "retval:%d", retval); + clixon_debug(CLIXON_DBG_INIT | CLIXON_DBG_DETAIL, "retval:%d", retval); if (wh != NULL) free(wh); if (retval != 1 && handle) @@ -418,7 +418,7 @@ clixon_plugins_load(clixon_handle h, plugin_module_struct *ms = plugin_module_struct_get(h); int dlflags; - clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, ""); + clixon_debug(CLIXON_DBG_INIT | CLIXON_DBG_DETAIL, ""); if (ms == NULL){ clixon_err(OE_PLUGIN, EINVAL, "plugin module not initialized"); goto done; @@ -429,7 +429,7 @@ clixon_plugins_load(clixon_handle h, /* Load all plugins */ for (i = 0; i < ndp; i++) { snprintf(filename, MAXPATHLEN-1, "%s/%s", dir, dp[i].d_name); - clixon_debug(CLIXON_DBG_DEFAULT, "Loading plugin '%s'", filename); + clixon_debug(CLIXON_DBG_INIT, "Loading plugin '%s'", filename); dlflags = RTLD_NOW; if (clicon_option_bool(h, "CLICON_PLUGIN_DLOPEN_GLOBAL")) dlflags |= RTLD_GLOBAL; @@ -471,7 +471,7 @@ clixon_pseudo_plugin(clixon_handle h, clixon_plugin_t *cp = NULL; plugin_module_struct *ms = plugin_module_struct_get(h); - clixon_debug(CLIXON_DBG_DEFAULT, "%s", name); + clixon_debug(CLIXON_DBG_INIT, "%s", name); if (ms == NULL){ clixon_err(OE_PLUGIN, EINVAL, "plugin module not initialized"); goto done; diff --git a/lib/src/clixon_sig.c b/lib/src/clixon_sig.c index a2faa7ae..bc8f7208 100644 --- a/lib/src/clixon_sig.c +++ b/lib/src/clixon_sig.c @@ -302,7 +302,7 @@ pidfile_write(char *pidfile) clixon_err(OE_DAEMON, errno, "Could not write pid to %s", pidfile); goto done; } - clixon_debug(CLIXON_DBG_DEFAULT, "Opened pidfile %s with pid %d", pidfile, getpid()); + clixon_debug(CLIXON_DBG_INIT, "Opened pidfile %s with pid %d", pidfile, getpid()); retval = 0; done: if (f != NULL)