summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorGergely Nagy <algernon@balabit.hu>2012-04-20 13:14:29 +0200
committerGergely Nagy <algernon@balabit.hu>2012-04-20 13:14:29 +0200
commit5509ee80130cb781d0c88d411021a98b5fab4556 (patch)
tree6300f9ca839c39e0deb952cc7e5c95d31d84a108 /t
parent32887a13759b27f5b29f585d2b278c225be1fa0d (diff)
downloadlibumberlog-5509ee80130cb781d0c88d411021a98b5fab4556.tar.gz
libumberlog-5509ee80130cb781d0c88d411021a98b5fab4556.tar.xz
libumberlog-5509ee80130cb781d0c88d411021a98b5fab4556.zip
Resolve facility & priority properly
The priority passed to the syslog() call can contain a facility embedded, so we need to extract it to find both the facility and the priority. This also means that the facility set at openlog()-time can be overridden later, so _find_facility() has to take the priority value into account. This patch makes libumberlog do just the above: extract both priority and facility from the priority passed to syslog(), and if facility is 0, use the default set at openlog()-time, if any. Added a test case to test this expected behaviour. Reported-by: Peter Czanik <czanik@balabit.hu> Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Diffstat (limited to 't')
-rw-r--r--t/test_umberlog.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/t/test_umberlog.c b/t/test_umberlog.c
index 26fbadb..33ed8bf 100644
--- a/t/test_umberlog.c
+++ b/t/test_umberlog.c
@@ -219,6 +219,23 @@ test_json_escape (void)
closelog ();
}
+static void
+test_facprio (void)
+{
+ char *msg;
+ struct json_object *jo;
+
+ msg = ul_format (LOG_LOCAL1 | LOG_DEBUG, "%s", __FUNCTION__,
+ NULL);
+ jo = parse_msg (msg);
+ free (msg);
+
+ verify_value (jo, "facility", "local1");
+ verify_value (jo, "priority", "debug");
+
+ json_object_put (jo);
+}
+
int
main (void)
{
@@ -228,6 +245,7 @@ main (void)
test_discover_priority ();
test_no_timestamp ();
test_json_escape ();
+ test_facprio ();
return 0;
}