From 5509ee80130cb781d0c88d411021a98b5fab4556 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Fri, 20 Apr 2012 13:14:29 +0200 Subject: 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 Signed-off-by: Gergely Nagy --- t/test_umberlog.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 't/test_umberlog.c') 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; } -- cgit