Skip to content

Commit

Permalink
Merge pull request #97 from tony-vanderpeet/log_error
Browse files Browse the repository at this point in the history
Improve logging
  • Loading branch information
tony-vanderpeet authored Nov 12, 2024
2 parents 945c8e0 + 2817290 commit 6dee470
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
10 changes: 8 additions & 2 deletions data.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,10 @@ _sch_xml_to_gnode (_sch_xml_to_gnode_parms *_parms, sch_node * schema, sch_ns *n
char *content = (char *) xmlNodeGetContent (xml);
if (_parms->in_is_edit && !sch_validate_pattern (schema, content))
{
DEBUG ("Invalid value \"%s\" for node \"%s\"\n", content, name);
if (logging & LOG_EDIT_CONFIG)
{
ERROR ("EDIT-CONFIG: Invalid value \"%s\" for node \"%s\"\n", content, name);
}
g_free (content);
apteryx_free_tree (tree);
_parms->out_error.tag = NC_ERR_TAG_INVALID_VAL;
Expand Down Expand Up @@ -875,7 +878,10 @@ _sch_xml_to_gnode (_sch_xml_to_gnode_parms *_parms, sch_node * schema, sch_ns *n
{
if (_parms->in_is_edit && !sch_validate_pattern (schema, value))
{
DEBUG ("Invalid value \"%s\" for node \"%s\"\n", value, name);
if (logging & LOG_EDIT_CONFIG)
{
ERROR ("EDIT-CONFIG: Invalid value \"%s\" for node \"%s\"\n", value, name);
}
free (value);
apteryx_free_tree (tree);
_parms->out_error.tag = NC_ERR_TAG_INVALID_VAL;
Expand Down
2 changes: 1 addition & 1 deletion logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ load_logging_options (void)
{
/* Remove any trailing LF */
buf[strcspn(buf, "\n")] = '\0';
split = g_strsplit (buf, " ", 6);
split = g_strsplit (buf, " ", 0);
count = g_strv_length (split);
for (i = 0; i < count; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion models/netconf-logging-options
Original file line number Diff line number Diff line change
@@ -1 +1 @@
edit-config get get-config kill-session lock unlock
edit-config get get-config kill-session lock unlock close-session
5 changes: 5 additions & 0 deletions netconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2137,12 +2137,17 @@ handle_edit (struct netconf_session *session, xmlNode * rpc)
}
}

/* Loop through conditions which are stored in the list as path, condition, path, condition, ... */
for (iter = sch_parm_conditions (parms); iter; iter = g_list_next (iter))
{
GList *next = g_list_next (iter);

if (next && !sch_process_condition (g_schema, tree, (char *) iter->data, (char *) next->data))
{
if (logging & LOG_EDIT_CONFIG)
{
ERROR ("EDIT-CONFIG: Path <%s> failed condition <%s>\n", (char *) iter->data, (char *) next->data);
}
ret = send_rpc_error_full (session, rpc, NC_ERR_TAG_INVALID_VAL, NC_ERR_TYPE_PROTOCOL, NULL, NULL, NULL, true);
sch_parm_free (parms);
apteryx_free_tree (tree);
Expand Down

0 comments on commit 6dee470

Please sign in to comment.