summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2012-07-24 12:36:34 +0200
committerMiloslav Trmač <mitr@redhat.com>2012-07-30 07:10:15 +0200
commit13dd8375af0dac1eac0132e1962f4edc5124d1b8 (patch)
treefd6d6f10796bb6c0bbf0b46563487457fc45c3f5
parentafcb5c504f7302165f34931864389cbc115b7b16 (diff)
downloadlibumberlog-13dd8375af0dac1eac0132e1962f4edc5124d1b8.tar.gz
libumberlog-13dd8375af0dac1eac0132e1962f4edc5124d1b8.tar.xz
libumberlog-13dd8375af0dac1eac0132e1962f4edc5124d1b8.zip
Change the default facility to LOG_USER.
... to comply with openlog(3p). Signed-off-by: Miloslav Trmač <mitr@redhat.com>
-rw-r--r--lib/umberlog.c4
-rw-r--r--t/test_umberlog.c20
2 files changed, 22 insertions, 2 deletions
diff --git a/lib/umberlog.c b/lib/umberlog.c
index 58f6bb0..ff9481c 100644
--- a/lib/umberlog.c
+++ b/lib/umberlog.c
@@ -76,7 +76,7 @@ static struct
the BSD syslog does the same thing). */
pthread_mutex_t lock;
int facility;
-} ul_process_data = { PTHREAD_MUTEX_INITIALIZER, 0 };
+} ul_process_data = { PTHREAD_MUTEX_INITIALIZER, LOG_USER };
static __thread ul_buffer_t ul_buffer;
static __thread int ul_recurse;
@@ -118,7 +118,7 @@ ul_closelog (void)
old_closelog ();
memset (&ul_thread_data, 0, sizeof (ul_thread_data));
pthread_mutex_lock (&ul_process_data.lock);
- ul_process_data.facility = 0;
+ ul_process_data.facility = LOG_USER;
pthread_mutex_unlock (&ul_process_data.lock);
}
diff --git a/t/test_umberlog.c b/t/test_umberlog.c
index 69d1a16..c3fdac8 100644
--- a/t/test_umberlog.c
+++ b/t/test_umberlog.c
@@ -294,6 +294,25 @@ START_TEST (test_positional_params)
END_TEST
#endif
+/* This must be the first test! */
+START_TEST (test_openlog_defaults)
+{
+ char *msg;
+ struct json_object *jo;
+
+ /* No openlog */
+
+ msg = ul_format (LOG_ALERT, "message", NULL);
+ jo = parse_msg (msg);
+ free (msg);
+
+ verify_value (jo, "facility", "user");
+ json_object_put (jo);
+
+ closelog ();
+}
+END_TEST
+
int
main (void)
{
@@ -305,6 +324,7 @@ main (void)
s = suite_create ("Umberlog functional testsuite");
ft = tcase_create ("Basic tests");
+ tcase_add_test (ft, test_openlog_defaults);
tcase_add_test (ft, test_simple);
tcase_add_test (ft, test_no_discover);
tcase_add_test (ft, test_additional_fields);