libyang REFACTOR simplify logging and extend location information
Simplify logger interface by using location information maintained in
the background. logger now prints all the available information: schema
path, data path and line numbers. However, the line number are quite
inaccurate (e.g. points to XML closing parent element) and some future
tuning would be great.
diff --git a/src/schema_features.c b/src/schema_features.c
index 15ffed9..bbcfa6f 100644
--- a/src/schema_features.c
+++ b/src/schema_features.c
@@ -299,8 +299,7 @@
uint64_t spaces;
for (spaces = 0; c[i + op_len + spaces] && isspace(c[i + op_len + spaces]); spaces++) {}
if (c[i + op_len + spaces] == '\0') {
- LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_SYNTAX_YANG,
- "Invalid value \"%s\" of if-feature - unexpected end of expression.", qname->str);
+ LOGVAL(ctx, LYVE_SYNTAX_YANG, "Invalid value \"%s\" of if-feature - unexpected end of expression.", qname->str);
return LY_EVALID;
} else if (!isspace(c[i + op_len])) {
/* feature name starting with the not/and/or */
@@ -316,7 +315,7 @@
}
} else { /* and, or */
if (f_exp != f_size) {
- LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_SYNTAX_YANG,
+ LOGVAL(ctx, LYVE_SYNTAX_YANG,
"Invalid value \"%s\" of if-feature - missing feature/expression before \"%.*s\" operation.",
qname->str, op_len, &c[i]);
return LY_EVALID;
@@ -343,14 +342,12 @@
}
if (j) {
/* not matching count of ( and ) */
- LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_SYNTAX_YANG,
- "Invalid value \"%s\" of if-feature - non-matching opening and closing parentheses.", qname->str);
+ LOGVAL(ctx, LYVE_SYNTAX_YANG, "Invalid value \"%s\" of if-feature - non-matching opening and closing parentheses.", qname->str);
return LY_EVALID;
}
if (f_exp != f_size) {
/* features do not match the needed arguments for the logical operations */
- LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_SYNTAX_YANG,
- "Invalid value \"%s\" of if-feature - number of features in expression does not match "
+ LOGVAL(ctx, LYVE_SYNTAX_YANG, "Invalid value \"%s\" of if-feature - number of features in expression does not match "
"the required number of operands for the operations.", qname->str);
return LY_EVALID;
}
@@ -358,8 +355,7 @@
if (checkversion || (expr_size > 1)) {
/* check that we have 1.1 module */
if (qname->mod->version != LYS_VERSION_1_1) {
- LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_SYNTAX_YANG,
- "Invalid value \"%s\" of if-feature - YANG 1.1 expression in YANG 1.0 module.", qname->str);
+ LOGVAL(ctx, LYVE_SYNTAX_YANG, "Invalid value \"%s\" of if-feature - YANG 1.1 expression in YANG 1.0 module.", qname->str);
return LY_EVALID;
}
}
@@ -427,7 +423,7 @@
/* now get the link to the feature definition */
f = lysp_feature_find(qname->mod, &c[i], j - i, 1);
if (!f) {
- LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_SYNTAX_YANG,
+ LOGVAL(ctx, LYVE_SYNTAX_YANG,
"Invalid value \"%s\" of if-feature - unable to find feature \"%.*s\".", qname->str, j - i, &c[i]);
rc = LY_EVALID;
goto error;
@@ -444,8 +440,7 @@
if (++expr_size || ++f_size) {
/* not all expected operators and operands found */
- LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_SYNTAX_YANG,
- "Invalid value \"%s\" of if-feature - processing error.", qname->str);
+ LOGVAL(ctx, LYVE_SYNTAX_YANG, "Invalid value \"%s\" of if-feature - processing error.", qname->str);
rc = LY_EINT;
} else {
rc = LY_SUCCESS;
@@ -636,8 +631,7 @@
for (u = 0; u < LY_ARRAY_COUNT(depfeatures); ++u) {
if (feature == depfeatures[u]) {
- LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_REFERENCE, "Feature \"%s\" is indirectly referenced from itself.",
- feature->name);
+ LOGVAL(ctx, LYVE_REFERENCE, "Feature \"%s\" is indirectly referenced from itself.", feature->name);
ret = LY_EVALID;
goto cleanup;
}
@@ -649,8 +643,7 @@
drv = recursion.objs[v];
for (u = 0; u < LY_ARRAY_COUNT(drv->depfeatures); ++u) {
if (feature == drv->depfeatures[u]) {
- LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_REFERENCE, "Feature \"%s\" is indirectly referenced from itself.",
- feature->name);
+ LOGVAL(ctx, LYVE_REFERENCE, "Feature \"%s\" is indirectly referenced from itself.", feature->name);
ret = LY_EVALID;
goto cleanup;
}
@@ -686,8 +679,7 @@
LY_ARRAY_FOR(f->iffeatures_c[u].features, v) {
/* check for circular dependency - direct reference first,... */
if (f == f->iffeatures_c[u].features[v]) {
- LOGVAL(pmod->mod->ctx, LY_VLOG_NONE, NULL, LYVE_REFERENCE, "Feature \"%s\" is referenced from itself.",
- f->name);
+ LOGVAL(pmod->mod->ctx, LYVE_REFERENCE, "Feature \"%s\" is referenced from itself.", f->name);
return LY_EVALID;
}
/* ... and indirect circular reference */