summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2012-07-24 12:49:08 +0200
committerMiloslav Trmač <mitr@redhat.com>2012-07-30 07:26:07 +0200
commit410e2d500152ed176ba8695fb9a938b0b9bfb545 (patch)
tree8c184a3dd30255a0adb4e60a370dd387f709f290
parent29fd70816db8d7b492734dadfd375362b7695876 (diff)
Don't include "program": "(null)" if ident is not set
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
-rw-r--r--lib/umberlog.c7
-rw-r--r--t/test_umberlog.c2
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/umberlog.c b/lib/umberlog.c
index d0fe6b6..aa5bded 100644
--- a/lib/umberlog.c
+++ b/lib/umberlog.c
@@ -492,11 +492,16 @@ _ul_discover (ul_buffer_t *buffer, int priority)
"pid", "%d", _find_pid (),
"facility", "%s", _find_facility (priority),
"priority", "%s", _find_prio (priority),
- "program", "%s", ul_process_data.ident,
"uid", "%d", _get_uid (),
"gid", "%d", _get_gid (),
"host", "%s", _get_hostname (),
NULL);
+ if (buffer == NULL)
+ return buffer;
+
+ if (ul_process_data.ident != NULL)
+ buffer = _ul_json_append (buffer, "program", "%s", ul_process_data.ident,
+ NULL);
if (ul_thread_data.flags & LOG_UL_NOTIME || !buffer)
return buffer;
diff --git a/t/test_umberlog.c b/t/test_umberlog.c
index 6bf1701..92644a6 100644
--- a/t/test_umberlog.c
+++ b/t/test_umberlog.c
@@ -258,6 +258,7 @@ START_TEST (test_closelog)
free (msg);
verify_value (jo, "facility", "local0");
+ verify_value_missing (jo, "program");
json_object_put (jo);
}
@@ -307,6 +308,7 @@ START_TEST (test_openlog_defaults)
free (msg);
verify_value (jo, "facility", "user");
+ verify_value_missing (jo, "program");
json_object_put (jo);
closelog ();