Skip to content

Commit

Permalink
filterx: add trace message for setattr and set-subscript
Browse files Browse the repository at this point in the history
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
  • Loading branch information
alltilla committed Apr 22, 2024
1 parent 029c95b commit 3cb6183
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
30 changes: 29 additions & 1 deletion lib/filterx/expr-set-subscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,35 @@ _eval(FilterXExpr *s)
filterx_object_unref(new_value);

if (filterx_object_set_subscript(object, key, cloned))
result = filterx_boolean_new(TRUE);
{
result = filterx_boolean_new(TRUE);
if (trace_flag)
{
GString *buf = scratch_buffers_alloc();
if (cloned && !filterx_object_repr(cloned, buf))
{
LogMessageValueType t;
if (!filterx_object_marshal(cloned, buf, &t))
g_assert_not_reached();
}

GString *key_buf = scratch_buffers_alloc();
if (!key)
{
g_string_assign(key_buf, "(null)");
}
else if (!filterx_object_repr(key, buf))
{
LogMessageValueType t;
if (!filterx_object_marshal(key, buf, &t))
g_assert_not_reached();
}

msg_trace("Filterx set-subscript",
evt_tag_mem("key", key_buf->str, key_buf->len),
evt_tag_mem("value", buf->str, buf->len));
}
}

filterx_object_unref(cloned);

Expand Down
17 changes: 16 additions & 1 deletion lib/filterx/expr-setattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,22 @@ _eval(FilterXExpr *s)
filterx_object_unref(new_value);

if (filterx_object_setattr(object, self->attr_name, cloned))
result = filterx_boolean_new(TRUE);
{
result = filterx_boolean_new(TRUE);
if (trace_flag)
{
GString *buf = scratch_buffers_alloc();
if (cloned && !filterx_object_repr(cloned, buf))
{
LogMessageValueType t;
if (!filterx_object_marshal(cloned, buf, &t))
g_assert_not_reached();
}
msg_trace("Filterx setattr",
evt_tag_str("attr_name", self->attr_name),
evt_tag_mem("value", buf->str, buf->len));
}
}

filterx_object_unref(cloned);

Expand Down

0 comments on commit 3cb6183

Please sign in to comment.