log UPDATE input logging cleared and updated
diff --git a/src/common.h b/src/common.h
index 9d80c25..264fe81 100644
--- a/src/common.h
+++ b/src/common.h
@@ -95,11 +95,9 @@
* @param[in] path Direct path string to print.
* @param[in] in Input handler (providing line number)
* @param[in] line One-time line value to be reset when used.
- * @param[in] reset Flag to indicate if the not set arguments (NULLs) are intended to rewrite the current values or if they
- * are supposed to be ignored and the previous values should be kept.
*/
void ly_log_location(const struct lysc_node *scnode, const struct lyd_node *dnode,
- const char *path, const struct ly_in *in, uint64_t line, ly_bool reset);
+ const char *path, const struct ly_in *in, uint64_t line);
/**
* @brief Revert the specific logger's location data by number of changes made by ::ly_log_location().
@@ -112,17 +110,6 @@
void ly_log_location_revert(uint32_t scnode_steps, uint32_t dnode_steps, uint32_t path_steps, uint32_t in_steps);
/**
- * @brief Initiate location data for logger, all arguments are set as provided (even NULLs) - overrides the current values.
- *
- * @param[in] SCNODE Compiled schema node.
- * @param[in] DNODE Data node.
- * @param[in] PATH Direct path string to print.
- * @param[in] IN Input handler (providing line number)
- */
-#define LOG_LOCINIT(SCNODE, DNODE, PATH, IN) \
- ly_log_location(SCNODE, DNODE, PATH, IN, 0, 1)
-
-/**
* @brief Update location data for logger, not provided arguments (NULLs) are kept (does not override).
*
* @param[in] SCNODE Compiled schema node.
@@ -131,7 +118,7 @@
* @param[in] IN Input handler (providing line number)
*/
#define LOG_LOCSET(SCNODE, DNODE, PATH, IN) \
- ly_log_location(SCNODE, DNODE, PATH, IN, 0, 0)
+ ly_log_location(SCNODE, DNODE, PATH, IN, 0)
/**
* @brief Update location data for logger, not provided arguments (NULLs) are kept (does not override).
@@ -171,7 +158,7 @@
#define LOGVAL(CTX, ...) ly_vlog(CTX, NULL, __VA_ARGS__)
#define LOGVAL_APPTAG(CTX, APPTAG, ...) ly_vlog(CTX, APPTAG, __VA_ARGS__)
#define LOGVAL_LINE(CTX, LINE, ...) \
- ly_log_location(NULL, NULL, NULL, NULL, LINE, 0); \
+ ly_log_location(NULL, NULL, NULL, NULL, LINE); \
ly_vlog(CTX, NULL, __VA_ARGS__)
/**
diff --git a/src/json.c b/src/json.c
index 59ae61c..ba711e1 100644
--- a/src/json.c
+++ b/src/json.c
@@ -868,7 +868,7 @@
jsonctx->ctx = ctx;
jsonctx->in = in;
- LOG_LOCINIT(NULL, NULL, NULL, in);
+ LOG_LOCSET(NULL, NULL, NULL, in);
/* parse JSON value, if any */
LY_CHECK_GOTO(ret = skip_ws(jsonctx), cleanup);
diff --git a/src/log.c b/src/log.c
index d13d327..243d030 100644
--- a/src/log.c
+++ b/src/log.c
@@ -273,35 +273,23 @@
void
ly_log_location(const struct lysc_node *scnode, const struct lyd_node *dnode, const char *path, const struct ly_in *in,
- uint64_t line, ly_bool reset)
+ uint64_t line)
{
if (scnode) {
ly_set_add(&log_location.scnodes, (void *)scnode, 1, NULL);
- } else if (reset) {
- ly_set_erase(&log_location.scnodes, NULL);
}
-
if (dnode) {
ly_set_add(&log_location.dnodes, (void *)dnode, 1, NULL);
- } else if (reset) {
- ly_set_erase(&log_location.dnodes, NULL);
}
-
if (path) {
char *s = strdup(path);
LY_CHECK_ERR_RET(!s, LOGMEM(NULL), );
ly_set_add(&log_location.paths, s, 1, NULL);
- } else if (reset) {
- ly_set_erase(&log_location.paths, free);
}
-
if (in) {
ly_set_add(&log_location.inputs, (void *)in, 1, NULL);
- } else if (reset) {
- ly_set_erase(&log_location.inputs, NULL);
}
-
if (line) {
log_location.line = line;
}
diff --git a/src/parser_json.c b/src/parser_json.c
index 2565c12..341fd7e 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -1796,6 +1796,10 @@
lyd_json_ctx_free((struct lyd_ctx *)lydctx);
} else {
*lydctx_p = (struct lyd_ctx *)lydctx;
+
+ /* the JSON context is no more needed, freeing it also stops logging line numbers which would be confusing now */
+ lyjson_ctx_free(lydctx->jsonctx);
+ lydctx->jsonctx = NULL;
}
return rc;
}
diff --git a/src/parser_yang.c b/src/parser_yang.c
index e28b3ae..522aae4 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -4713,7 +4713,7 @@
(*context)->parsed_mods = main_ctx->parsed_mods;
ly_set_add((*context)->parsed_mods, mod_p, 1, NULL);
- LOG_LOCINIT(NULL, NULL, NULL, in);
+ LOG_LOCSET(NULL, NULL, NULL, in);
/* skip redundant but valid characters at the beginning */
ret = skip_redundant_chars(*context);
@@ -4783,7 +4783,7 @@
mod_p->mod = mod;
ly_set_add((*context)->parsed_mods, mod_p, 1, NULL);
- LOG_LOCINIT(NULL, NULL, NULL, in);
+ LOG_LOCSET(NULL, NULL, NULL, in);
/* skip redundant but valid characters at the beginning */
ret = skip_redundant_chars(*context);
diff --git a/src/tree_schema.c b/src/tree_schema.c
index d225903..9c0d876 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -1325,7 +1325,7 @@
if ((r = lysp_resolve_ext_instance_log_path(pctx, ext, &path))) {
return r;
}
- LOG_LOCINIT(NULL, NULL, path, NULL);
+ LOG_LOCSET(NULL, NULL, path, NULL);
/* parse */
r = ext->record->plugin.parse(pctx, ext);
diff --git a/src/xml.c b/src/xml.c
index 4be93dd..a0994bd 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -904,7 +904,7 @@
xmlctx->ctx = ctx;
xmlctx->in = in;
- LOG_LOCINIT(NULL, NULL, NULL, in);
+ LOG_LOCSET(NULL, NULL, NULL, in);
/* parse next element, if any */
LY_CHECK_GOTO(ret = lyxml_next_element(xmlctx, &xmlctx->prefix, &xmlctx->prefix_len, &xmlctx->name,
diff --git a/tests/utests/basic/test_xml.c b/tests/utests/basic/test_xml.c
index efc8a61..668de4b 100644
--- a/tests/utests/basic/test_xml.c
+++ b/tests/utests/basic/test_xml.c
@@ -390,7 +390,7 @@
/* empty value but in single quotes */
assert_int_equal(LY_SUCCESS, ly_in_new_memory("=\'\'", &in));
xmlctx->in = in;
- LOG_LOCINIT(NULL, NULL, NULL, in);
+ LOG_LOCSET(NULL, NULL, NULL, in);
xmlctx->status = LYXML_ATTRIBUTE;
assert_int_equal(LY_SUCCESS, lyxml_ctx_next(xmlctx));
assert_int_equal(LYXML_ATTR_CONTENT, xmlctx->status);
@@ -402,7 +402,7 @@
/* empty element content - only formating before defining child */
assert_int_equal(LY_SUCCESS, ly_in_new_memory(">\n <y>", &in));
xmlctx->in = in;
- LOG_LOCINIT(NULL, NULL, NULL, in);
+ LOG_LOCSET(NULL, NULL, NULL, in);
xmlctx->status = LYXML_ELEMENT;
assert_int_equal(LY_SUCCESS, lyxml_ctx_next(xmlctx));
assert_int_equal(LYXML_ELEM_CONTENT, xmlctx->status);
@@ -414,7 +414,7 @@
/* empty element content is invalid - missing content terminating character < */
assert_int_equal(LY_SUCCESS, ly_in_new_memory("", &in));
xmlctx->in = in;
- LOG_LOCINIT(NULL, NULL, NULL, in);
+ LOG_LOCSET(NULL, NULL, NULL, in);
xmlctx->status = LYXML_ELEM_CONTENT;
assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
CHECK_LOG_CTX("Unexpected end-of-input.", "Line number 1.");
@@ -422,7 +422,7 @@
assert_int_equal(LY_SUCCESS, ly_in_new_memory("xxx", &in));
xmlctx->in = in;
- LOG_LOCINIT(NULL, NULL, NULL, in);
+ LOG_LOCSET(NULL, NULL, NULL, in);
xmlctx->status = LYXML_ELEM_CONTENT;
assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
CHECK_LOG_CTX("Invalid character sequence \"xxx\", expected element tag start ('<').", "Line number 1.");
@@ -448,7 +448,7 @@
/* test using n-bytes UTF8 hexadecimal code points */
assert_int_equal(LY_SUCCESS, ly_in_new_memory("=\'$¢€𐍈\'", &in));
xmlctx->in = in;
- LOG_LOCINIT(NULL, NULL, NULL, in);
+ LOG_LOCSET(NULL, NULL, NULL, in);
xmlctx->status = LYXML_ATTRIBUTE;
assert_int_equal(LY_SUCCESS, lyxml_ctx_next(xmlctx));
assert_int_equal(LYXML_ATTR_CONTENT, xmlctx->status);
@@ -460,7 +460,7 @@
/* CDATA value */
assert_int_equal(LY_SUCCESS, ly_in_new_memory("> <![CDATA[ special non-escaped chars <>&\"' ]]> </a>", &in));
xmlctx->in = in;
- LOG_LOCINIT(NULL, NULL, NULL, in);
+ LOG_LOCSET(NULL, NULL, NULL, in);
xmlctx->status = LYXML_ATTR_CONTENT;
assert_int_equal(LY_SUCCESS, lyxml_ctx_next(xmlctx));
assert_int_equal(LYXML_ELEM_CONTENT, xmlctx->status);
@@ -473,7 +473,7 @@
/* invalid characters in string */
assert_int_equal(LY_SUCCESS, ly_in_new_memory("=\'R\'", &in));
xmlctx->in = in;
- LOG_LOCINIT(NULL, NULL, NULL, in);
+ LOG_LOCSET(NULL, NULL, NULL, in);
xmlctx->status = LYXML_ATTRIBUTE;
assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
CHECK_LOG_CTX("Invalid character sequence \"'\", expected ;.", "Line number 1.");
@@ -481,7 +481,7 @@
assert_int_equal(LY_SUCCESS, ly_in_new_memory("=\"R\"", &in));
xmlctx->in = in;
- LOG_LOCINIT(NULL, NULL, NULL, in);
+ LOG_LOCSET(NULL, NULL, NULL, in);
xmlctx->status = LYXML_ATTRIBUTE;
assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
CHECK_LOG_CTX("Invalid character sequence \"\"\", expected ;.", "Line number 1.");
@@ -489,7 +489,7 @@
assert_int_equal(LY_SUCCESS, ly_in_new_memory("=\"&nonsense;\"", &in));
xmlctx->in = in;
- LOG_LOCINIT(NULL, NULL, NULL, in);
+ LOG_LOCSET(NULL, NULL, NULL, in);
xmlctx->status = LYXML_ATTRIBUTE;
assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
CHECK_LOG_CTX("Entity reference \"&nonsense;\" not supported, only predefined references allowed.", "Line number 1.");
@@ -497,7 +497,7 @@
assert_int_equal(LY_SUCCESS, ly_in_new_memory(">&#o122;", &in));
xmlctx->in = in;
- LOG_LOCINIT(NULL, NULL, NULL, in);
+ LOG_LOCSET(NULL, NULL, NULL, in);
xmlctx->status = LYXML_ELEMENT;
assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
CHECK_LOG_CTX("Invalid character reference \"&#o122;\".", "Line number 1.");
@@ -505,7 +505,7 @@
assert_int_equal(LY_SUCCESS, ly_in_new_memory("=\'\'", &in));
xmlctx->in = in;
- LOG_LOCINIT(NULL, NULL, NULL, in);
+ LOG_LOCSET(NULL, NULL, NULL, in);
xmlctx->status = LYXML_ATTRIBUTE;
assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
CHECK_LOG_CTX("Invalid character reference \"\'\" (0x00000006).", "Line number 1.");
@@ -513,7 +513,7 @@
assert_int_equal(LY_SUCCESS, ly_in_new_memory("=\'\'", &in));
xmlctx->in = in;
- LOG_LOCINIT(NULL, NULL, NULL, in);
+ LOG_LOCSET(NULL, NULL, NULL, in);
xmlctx->status = LYXML_ATTRIBUTE;
assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
CHECK_LOG_CTX("Invalid character reference \"\'\" (0x0000fdd0).", "Line number 1.");
@@ -521,7 +521,7 @@
assert_int_equal(LY_SUCCESS, ly_in_new_memory("=\'\'", &in));
xmlctx->in = in;
- LOG_LOCINIT(NULL, NULL, NULL, in);
+ LOG_LOCSET(NULL, NULL, NULL, in);
xmlctx->status = LYXML_ATTRIBUTE;
assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
CHECK_LOG_CTX("Invalid character reference \"\'\" (0x0000ffff).", "Line number 1.");
diff --git a/tests/utests/data/test_parser_json.c b/tests/utests/data/test_parser_json.c
index 3dd5eb4..a33416f 100644
--- a/tests/utests/data/test_parser_json.c
+++ b/tests/utests/data/test_parser_json.c
@@ -555,7 +555,7 @@
/* invalid metadata */
data = "{\"@a:foo\":\"str\",\"@a:foo3\":1,\"a:foo3\":2}";
PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
- "Unknown module of node \"@a:foo\".", "Data location \"/@a:foo\", line number 1.");
+ "Unknown module of node \"@a:foo\".", "Data location \"/@a:foo\".");
/* empty name */
PARSER_CHECK_ERROR("{\"@a:foo\":{\"\":0}}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
diff --git a/tests/utests/extensions/test_schema_mount.c b/tests/utests/extensions/test_schema_mount.c
index ded8ce6..be879ec 100644
--- a/tests/utests/extensions/test_schema_mount.c
+++ b/tests/utests/extensions/test_schema_mount.c
@@ -297,9 +297,11 @@
" <module-set-id>1</module-set-id>"
"</modules-state>");
CHECK_PARSE_LYD_PARAM(xml, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
- CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.", "Line number 1.");
+ CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.",
+ "Data location \"/sm:root\", line number 1.");
CHECK_PARSE_LYD_PARAM(json, LYD_JSON, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
- CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.", "Line number 1.");
+ CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.",
+ "Data location \"/sm:root\", line number 1.");
/* missing module in yang-library data */
ly_ctx_set_ext_data_clb(UTEST_LYCTX, test_ext_data_clb,
@@ -338,9 +340,11 @@
" </mount-point>"
"</schema-mounts>");
CHECK_PARSE_LYD_PARAM(xml, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
- CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.", NULL);
+ CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.",
+ "Data location \"/sm:root\", line number 1.");
CHECK_PARSE_LYD_PARAM(json, LYD_JSON, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
- CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.", NULL);
+ CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.",
+ "Data location \"/sm:root\", line number 1.");
/* callback data correct, invalid YANG data */
ly_ctx_set_ext_data_clb(UTEST_LYCTX, test_ext_data_clb,
@@ -1155,7 +1159,7 @@
CHECK_PARSE_LYD_PARAM(json, LYD_JSON, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": "
"Invalid leafref value \"target-value\" - no target instance \"/sm:target\" with the same value.",
- "Data location \"/ietf-interfaces:interfaces/interface[name='bu']/sm:sm-name\", line number 18.");
+ "Data location \"/ietf-interfaces:interfaces/interface[name='bu']/sm:sm-name\".");
/* success */
xml =
diff --git a/tests/utests/node/list.c b/tests/utests/node/list.c
index f89c56a..8b14ece 100644
--- a/tests/utests/node/list.c
+++ b/tests/utests/node/list.c
@@ -1205,7 +1205,7 @@
CHECK_PARSE_LYD_PARAM(data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
assert_null(tree);
CHECK_LOG_CTX("Duplicate instance of \"user\".",
- "Data location \"/T0:user[uid='0']\", line number 1.");
+ "Data location \"/T0:user[uid='0']\".");
data =
"{\"T0:user\": ["
@@ -1215,7 +1215,7 @@
CHECK_PARSE_LYD_PARAM(data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
assert_null(tree);
CHECK_LOG_CTX("Unique data leaf(s) \"name group\" not satisfied in \"/T0:user[uid='0']\" and \"/T0:user[uid='1']\".",
- "Data location \"/T0:user[uid='1']\", line number 1.");
+ "Data location \"/T0:user[uid='1']\".");
/* double key */
schema = MODULE_CREATE_YANG("T1", "list user {"
@@ -1265,7 +1265,7 @@
CHECK_PARSE_LYD_PARAM(data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
assert_null(tree);
CHECK_LOG_CTX("Duplicate instance of \"user\".",
- "Data location \"/T1:user[uid='0'][group='User']\", line number 1.");
+ "Data location \"/T1:user[uid='0'][group='User']\".");
/* min elements max elements */
schema = MODULE_CREATE_YANG("T2",
@@ -1353,7 +1353,7 @@
CHECK_PARSE_LYD_PARAM(data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
assert_null(tree);
CHECK_LOG_CTX("Too few \"user\" instances.",
- "Schema location \"/T2:user\", line number 1.");
+ "Schema location \"/T2:user\".");
data =
"{\"T2:user\": ["
@@ -1367,7 +1367,7 @@
CHECK_PARSE_LYD_PARAM(data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
assert_null(tree);
CHECK_LOG_CTX("Too many \"user\" instances.",
- "Data location \"/T2:user[uid='5']\", line number 1.");
+ "Data location \"/T2:user[uid='5']\".");
schema = MODULE_CREATE_YANG("T_EMPTY_LIST",
"container user_list {"
diff --git a/tests/utests/schema/test_yang.c b/tests/utests/schema/test_yang.c
index 4f11500..4ce4dc4 100644
--- a/tests/utests/schema/test_yang.c
+++ b/tests/utests/schema/test_yang.c
@@ -90,7 +90,7 @@
/* initilize and use the global easily available and customizable input handler */
in.line = 1;
YCTX->in = ∈
- LOG_LOCINIT(NULL, NULL, NULL, &in);
+ LOG_LOCSET(NULL, NULL, NULL, &in);
fctx.ctx = PARSER_CTX(YCTX);
fctx.mod = pmod->mod;