Add datastore-specific logging
This commit is contained in:
parent
42a92f262a
commit
23b538e7dc
3 changed files with 22 additions and 20 deletions
|
|
@ -56,13 +56,14 @@
|
||||||
|
|
||||||
/* Subject area */
|
/* Subject area */
|
||||||
#define CLIXON_DBG_DEFAULT 0x000001 /* Default logs */
|
#define CLIXON_DBG_DEFAULT 0x000001 /* Default logs */
|
||||||
#define CLIXON_DBG_MSG 0x000002 /* In/out messages and datastore reads */
|
#define CLIXON_DBG_MSG 0x000002 /* In/out messages */
|
||||||
#define CLIXON_DBG_XML 0x000004 /* XML processing */
|
#define CLIXON_DBG_XML 0x000004 /* XML processing */
|
||||||
#define CLIXON_DBG_XPATH 0x000008 /* XPath processing */
|
#define CLIXON_DBG_XPATH 0x000008 /* XPath processing */
|
||||||
#define CLIXON_DBG_YANG 0x000010 /* YANG processing */
|
#define CLIXON_DBG_YANG 0x000010 /* YANG processing */
|
||||||
#define CLIXON_DBG_CLIENT 0x000020 /* App-specific */
|
#define CLIXON_DBG_CLIENT 0x000020 /* App-specific */
|
||||||
#define CLIXON_DBG_NACM 0x000040 /* NACM processing */
|
#define CLIXON_DBG_NACM 0x000040 /* NACM processing */
|
||||||
#define CLIXON_DBG_PROC 0x000080 /* Process handling */
|
#define CLIXON_DBG_PROC 0x000080 /* Process handling */
|
||||||
|
#define CLIXON_DBG_DATASTORE 0x000100 /* Datastore management */
|
||||||
#define CLIXON_DBG_SMASK 0x00ffff /* Subject mask */
|
#define CLIXON_DBG_SMASK 0x00ffff /* Subject mask */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,7 @@ xmldb_copy(clixon_handle h,
|
||||||
cxobj *x1 = NULL; /* from */
|
cxobj *x1 = NULL; /* from */
|
||||||
cxobj *x2 = NULL; /* to */
|
cxobj *x2 = NULL; /* to */
|
||||||
|
|
||||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s %s", from, to);
|
clixon_debug(CLIXON_DBG_DATASTORE, "%s %s", from, to);
|
||||||
/* XXX lock */
|
/* XXX lock */
|
||||||
if (clicon_datastore_cache(h) != DATASTORE_NOCACHE){
|
if (clicon_datastore_cache(h) != DATASTORE_NOCACHE){
|
||||||
/* Copy in-memory cache */
|
/* Copy in-memory cache */
|
||||||
|
|
@ -237,6 +237,7 @@ xmldb_copy(clixon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
clixon_debug(CLIXON_DBG_DATASTORE, "retval:%d", retval);
|
||||||
if (fromfile)
|
if (fromfile)
|
||||||
free(fromfile);
|
free(fromfile);
|
||||||
if (tofile)
|
if (tofile)
|
||||||
|
|
@ -265,7 +266,7 @@ xmldb_lock(clixon_handle h,
|
||||||
de0.de_id = id;
|
de0.de_id = id;
|
||||||
gettimeofday(&de0.de_tv, NULL);
|
gettimeofday(&de0.de_tv, NULL);
|
||||||
clicon_db_elmnt_set(h, db, &de0);
|
clicon_db_elmnt_set(h, db, &de0);
|
||||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s: locked by %u", db, id);
|
clixon_debug(CLIXON_DBG_DATASTORE, "%s: locked by %u", db, id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -384,7 +385,7 @@ xmldb_exists(clixon_handle h,
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
|
||||||
clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, "%s", db);
|
clixon_debug(CLIXON_DBG_DATASTORE | CLIXON_DBG_DETAIL, "%s", db);
|
||||||
if (xmldb_db2file(h, db, &filename) < 0)
|
if (xmldb_db2file(h, db, &filename) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (lstat(filename, &sb) < 0)
|
if (lstat(filename, &sb) < 0)
|
||||||
|
|
@ -397,6 +398,7 @@ xmldb_exists(clixon_handle h,
|
||||||
retval = 1;
|
retval = 1;
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
|
clixon_debug(CLIXON_DBG_DATASTORE | CLIXON_DBG_DETAIL, "retval:%d", retval);
|
||||||
if (filename)
|
if (filename)
|
||||||
free(filename);
|
free(filename);
|
||||||
return retval;
|
return retval;
|
||||||
|
|
@ -442,7 +444,7 @@ xmldb_delete(clixon_handle h,
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
|
||||||
clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, "%s", db);
|
clixon_debug(CLIXON_DBG_DATASTORE | CLIXON_DBG_DETAIL, "%s", db);
|
||||||
if (xmldb_clear(h, db) < 0)
|
if (xmldb_clear(h, db) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (xmldb_db2file(h, db, &filename) < 0)
|
if (xmldb_db2file(h, db, &filename) < 0)
|
||||||
|
|
@ -454,6 +456,7 @@ xmldb_delete(clixon_handle h,
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
clixon_debug(CLIXON_DBG_DATASTORE | CLIXON_DBG_DETAIL, "retval:%d", retval);
|
||||||
if (filename)
|
if (filename)
|
||||||
free(filename);
|
free(filename);
|
||||||
return retval;
|
return retval;
|
||||||
|
|
@ -476,7 +479,7 @@ xmldb_create(clixon_handle h,
|
||||||
db_elmnt *de = NULL;
|
db_elmnt *de = NULL;
|
||||||
cxobj *xt = NULL;
|
cxobj *xt = NULL;
|
||||||
|
|
||||||
clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, "%s", db);
|
clixon_debug(CLIXON_DBG_DATASTORE | CLIXON_DBG_DETAIL, "%s", db);
|
||||||
if ((de = clicon_db_elmnt_get(h, db)) != NULL){
|
if ((de = clicon_db_elmnt_get(h, db)) != NULL){
|
||||||
if ((xt = de->de_xml) != NULL){
|
if ((xt = de->de_xml) != NULL){
|
||||||
xml_free(xt);
|
xml_free(xt);
|
||||||
|
|
@ -489,8 +492,9 @@ xmldb_create(clixon_handle h,
|
||||||
clixon_err(OE_UNIX, errno, "open(%s)", filename);
|
clixon_err(OE_UNIX, errno, "open(%s)", filename);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
clixon_debug(CLIXON_DBG_DATASTORE | CLIXON_DBG_DETAIL, "retval:%d", retval);
|
||||||
if (filename)
|
if (filename)
|
||||||
free(filename);
|
free(filename);
|
||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
|
|
|
||||||
|
|
@ -500,7 +500,7 @@ xmldb_readfile(clixon_handle h,
|
||||||
clixon_err(OE_CFG, ENOENT, "No CLICON_XMLDB_FORMAT");
|
clixon_err(OE_CFG, ENOENT, "No CLICON_XMLDB_FORMAT");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
clixon_debug(CLIXON_DBG_DEFAULT, "Reading datastore %s using %s", dbfile, format);
|
clixon_debug(CLIXON_DBG_DATASTORE, "Reading datastore %s using %s", dbfile, format);
|
||||||
/* Parse file into internal XML tree from different formats */
|
/* Parse file into internal XML tree from different formats */
|
||||||
if ((fp = fopen(dbfile, "r")) == NULL) {
|
if ((fp = fopen(dbfile, "r")) == NULL) {
|
||||||
clixon_err(OE_UNIX, errno, "open(%s)", dbfile);
|
clixon_err(OE_UNIX, errno, "open(%s)", dbfile);
|
||||||
|
|
@ -796,14 +796,12 @@ xmldb_get_nocache(clixon_handle h,
|
||||||
if (disable_nacm_on_empty(xt, yspec) < 0)
|
if (disable_nacm_on_empty(xt, yspec) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (clixon_debug_isset(CLIXON_DBG_DEFAULT))
|
clixon_debug_xml(CLIXON_DBG_DATASTORE | CLIXON_DBG_DETAIL, xt, "");
|
||||||
if (clixon_xml2file(stderr, xt, 0, 1, NULL, fprintf, 0, 0) < 0)
|
|
||||||
goto done;
|
|
||||||
*xtop = xt;
|
*xtop = xt;
|
||||||
xt = NULL;
|
xt = NULL;
|
||||||
retval = 1;
|
retval = 1;
|
||||||
done:
|
done:
|
||||||
clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, "retval:%d", retval);
|
clixon_debug(CLIXON_DBG_DATASTORE | CLIXON_DBG_DETAIL, "retval:%d", retval);
|
||||||
if (xt)
|
if (xt)
|
||||||
xml_free(xt);
|
xml_free(xt);
|
||||||
if (xvec)
|
if (xvec)
|
||||||
|
|
@ -860,6 +858,8 @@ xmldb_get_cache(clixon_handle h,
|
||||||
db_elmnt de0 = {0,};
|
db_elmnt de0 = {0,};
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
clixon_debug(CLIXON_DBG_DATASTORE | CLIXON_DBG_DETAIL, "db %s", db);
|
||||||
|
|
||||||
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
||||||
clixon_err(OE_YANG, ENOENT, "No yang spec");
|
clixon_err(OE_YANG, ENOENT, "No yang spec");
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -991,11 +991,11 @@ xmldb_get_cache(clixon_handle h,
|
||||||
if (disable_nacm_on_empty(x1t, yspec) < 0)
|
if (disable_nacm_on_empty(x1t, yspec) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
clixon_debug_xml(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, x1t, "");
|
clixon_debug_xml(CLIXON_DBG_DATASTORE | CLIXON_DBG_DETAIL, x1t, "");
|
||||||
*xtop = x1t;
|
*xtop = x1t;
|
||||||
retval = 1;
|
retval = 1;
|
||||||
done:
|
done:
|
||||||
clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, "retval:%d", retval);
|
clixon_debug(CLIXON_DBG_DATASTORE | CLIXON_DBG_DETAIL, "retval:%d", retval);
|
||||||
if (xvec)
|
if (xvec)
|
||||||
free(xvec);
|
free(xvec);
|
||||||
return retval;
|
return retval;
|
||||||
|
|
@ -1040,7 +1040,6 @@ xmldb_get_zerocopy(clixon_handle h,
|
||||||
cxobj **xvec = NULL;
|
cxobj **xvec = NULL;
|
||||||
size_t xlen;
|
size_t xlen;
|
||||||
int i;
|
int i;
|
||||||
cxobj *x0;
|
|
||||||
db_elmnt *de = NULL;
|
db_elmnt *de = NULL;
|
||||||
db_elmnt de0 = {0,};
|
db_elmnt de0 = {0,};
|
||||||
int ret;
|
int ret;
|
||||||
|
|
@ -1075,7 +1074,7 @@ xmldb_get_zerocopy(clixon_handle h,
|
||||||
* For every node found in x0, mark the tree up to t1
|
* For every node found in x0, mark the tree up to t1
|
||||||
*/
|
*/
|
||||||
for (i=0; i<xlen; i++){
|
for (i=0; i<xlen; i++){
|
||||||
x0 = xvec[i];
|
cxobj *x0 = xvec[i];
|
||||||
xml_flag_set(x0, XML_FLAG_MARK);
|
xml_flag_set(x0, XML_FLAG_MARK);
|
||||||
xml_apply_ancestor(x0, (xml_applyfn_t*)xml_flag_set, (void*)XML_FLAG_CHANGE);
|
xml_apply_ancestor(x0, (xml_applyfn_t*)xml_flag_set, (void*)XML_FLAG_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
@ -1140,13 +1139,11 @@ xmldb_get_zerocopy(clixon_handle h,
|
||||||
if (disable_nacm_on_empty(x0t, yspec) < 0)
|
if (disable_nacm_on_empty(x0t, yspec) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (clixon_debug_isset(CLIXON_DBG_DEFAULT))
|
clixon_debug_xml(CLIXON_DBG_DATASTORE | CLIXON_DBG_DETAIL, x0t, "");
|
||||||
if (clixon_xml2file(stderr, x0t, 0, 1, NULL, fprintf, 0, 0) < 0)
|
|
||||||
goto done;
|
|
||||||
*xtop = x0t;
|
*xtop = x0t;
|
||||||
retval = 1;
|
retval = 1;
|
||||||
done:
|
done:
|
||||||
clixon_debug(CLIXON_DBG_DEFAULT | CLIXON_DBG_DETAIL, "retval:%d", retval);
|
clixon_debug(CLIXON_DBG_DATASTORE | CLIXON_DBG_DETAIL, "retval:%d", retval);
|
||||||
if (xvec)
|
if (xvec)
|
||||||
free(xvec);
|
free(xvec);
|
||||||
return retval;
|
return retval;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue