summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGergely Nagy <algernon@balabit.hu>2012-08-11 01:06:55 +0200
committerGergely Nagy <algernon@balabit.hu>2012-08-11 01:06:55 +0200
commitfbeba09ae5050ef0adf2791b9d1a29993e9f6658 (patch)
tree31c56e0599a72184b3835a5f0f5cf48e640db026
parent1c707ea147d40ff2119b430512fe4e45c564ce32 (diff)
downloadlibumberlog-fbeba09ae5050ef0adf2791b9d1a29993e9f6658.tar.gz
libumberlog-fbeba09ae5050ef0adf2791b9d1a29993e9f6658.tar.xz
libumberlog-fbeba09ae5050ef0adf2791b9d1a29993e9f6658.zip
LOG_UL_NODISCOVER => LOG_UL_NOIMPLICIT
Based on a suggestion by Miloslav Trmač <mitr@redhat.com>, rename LOG_UL_NODISCOVER to LOG_UL_NOIMPLICIT, and clarify the documentation slightly. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
-rw-r--r--configure.ac10
-rw-r--r--lib/umberlog.c8
-rw-r--r--lib/umberlog.h2
-rw-r--r--lib/umberlog.rst21
-rw-r--r--t/test_perf.c8
-rw-r--r--t/test_umberlog.c38
-rw-r--r--t/test_umberlog_preload.c35
7 files changed, 65 insertions, 57 deletions
diff --git a/configure.ac b/configure.ac
index 233382a..0f43e65 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,15 +75,15 @@ AC_TYPE_SIZE_T
AC_ARG_ENABLE([discovery],
AS_HELP_STRING([--disable-discovery],
- [Do not add automatically-discovered field when using the LD_PRELOAD lib [default=enabled]]),
+ [Do not implicitly add automatically discovered fields when using the LD_PRELOAD lib [default=enabled]]),
[], [enable_discovery=yes])
if test "x$enable_discovery" != xno; then
- DEFAULT_DISCOVER_FLAGS=LOG_UL_ALL
+ DEFAULT_LOG_FLAGS=LOG_UL_ALL
else
- DEFAULT_DISCOVER_FLAGS=LOG_UL_NODISCOVER
+ DEFAULT_LOG_FLAGS=LOG_UL_NOIMPLICIT
fi
-AC_DEFINE_UNQUOTED([DEFAULT_DISCOVER_FLAGS], [$DEFAULT_DISCOVER_FLAGS],
- [Default flags if ul_set_log_flags() is not called])
+AC_DEFINE_UNQUOTED([DEFAULT_LOG_FLAGS], [$DEFAULT_LOG_FLAGS],
+ [Default flags for the LD_PRELOAD variant of the library])
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [package name])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [version number])
diff --git a/lib/umberlog.c b/lib/umberlog.c
index b64d715..e0ce093 100644
--- a/lib/umberlog.c
+++ b/lib/umberlog.c
@@ -79,7 +79,7 @@ static struct
{
PTHREAD_MUTEX_INITIALIZER,
#if __UL_PRELOAD__
- DEFAULT_DISCOVER_FLAGS,
+ DEFAULT_LOG_FLAGS,
#else
LOG_UL_ALL,
#endif
@@ -109,9 +109,9 @@ ul_finish (void)
static void
_ul_reset_caches_locked (void)
{
- /* If either NODISCOVER or NOCACHE is set, don't cache stuff we
+ /* If either NOIMPLICIT or NOCACHE is set, don't cache stuff we
won't use. */
- if ((ul_process_data.flags & (LOG_UL_NODISCOVER | LOG_UL_NOCACHE)) != 0)
+ if ((ul_process_data.flags & (LOG_UL_NOIMPLICIT | LOG_UL_NOCACHE)) != 0)
{
ul_process_data.pid = -1;
ul_process_data.gid = -1;
@@ -560,7 +560,7 @@ _ul_discover (ul_buffer_t *buffer, int priority)
char hostname_buffer[_POSIX_HOST_NAME_MAX + 1];
const char *ident;
- if (ul_process_data.flags & LOG_UL_NODISCOVER)
+ if (ul_process_data.flags & LOG_UL_NOIMPLICIT)
return buffer;
buffer = _ul_json_append (buffer,
diff --git a/lib/umberlog.h b/lib/umberlog.h
index 85f7b6e..2a0d08b 100644
--- a/lib/umberlog.h
+++ b/lib/umberlog.h
@@ -32,7 +32,7 @@
#include <stdarg.h>
#define LOG_UL_ALL 0x0000
-#define LOG_UL_NODISCOVER 0x0040
+#define LOG_UL_NOIMPLICIT 0x0040
#define LOG_UL_NOCACHE 0x0080
#define LOG_UL_NOCACHE_UID 0x0100
#define LOG_UL_NOTIME 0x0200
diff --git a/lib/umberlog.rst b/lib/umberlog.rst
index 7c3af99..65c824b 100644
--- a/lib/umberlog.rst
+++ b/lib/umberlog.rst
@@ -7,7 +7,7 @@ CEE-enhanced syslog message generation
--------------------------------------
:Author: Gergely Nagy <algernon@balabit.hu>
-:Date: 2012-08-10
+:Date: 2012-08-11
:Manual section: 3
:Manual group: CEE-enhanced syslog Manual
@@ -88,7 +88,7 @@ ones and the new ones too turn the original syslog message into a
CEE-enabled JSON payload, with the original message put into the *msg*
field, and any additional fields put into the same structure.
-By default, unless the **LOG_UL_NODISCOVER** option flag is set, all
+By default, unless the **LOG_UL_NOIMPLICIT** option flag is set, all
of these functions will also add a few automatically discovered fields
into the payload:
@@ -128,22 +128,23 @@ LOG_UL_ALL
setting for the linkable library, but for the LD_PRELOAD variant, it
can be changed at the library's configure time.
-LOG_UL_NODISCOVER
- Disable all automatic discovery, and only include the *message*,
- and any specified *key-value* pairs in the generated message.
+LOG_UL_NOIMPLICIT
+ Disable adding any automatic discovered fields implicitly, and only
+ include the *message*, and any specified *key-value* pairs in the
+ generated message.
LOG_UL_NOCACHE
- When automatic discovery is enabled, disable caching certain
- properties, that might change between the call to **openlog()** and
- the **ul_syslog()** invocation.
+ When implict fields are enabled, disable caching certain properties,
+ that might change between the call to **openlog()** and the
+ **ul_syslog()** invocation.
LOG_UL_NOCACHE_UID
- Disable the *uid* and *gid* caching when automatic discovery is
+ Disable the *uid* and *gid* caching when implicit fields are
enabled, but do cache the rest.
LOG_UL_NOTIME
Do not add a high-precision timestamp to the generated message when
- automatic discovery is enabled.
+ implicit fields are enabled.
EXAMPLES
========
diff --git a/t/test_perf.c b/t/test_perf.c
index 0494110..f1eb628 100644
--- a/t/test_perf.c
+++ b/t/test_perf.c
@@ -44,8 +44,8 @@ test_perf_simple (int flags, unsigned long cnt)
dt = ts_diff (st, et);
- if (flags & LOG_UL_NODISCOVER)
- fls = "no-discover";
+ if (flags & LOG_UL_NOIMPLICIT)
+ fls = "no-implicit";
else if (flags & LOG_UL_NOTIME)
fls = "no-time";
else
@@ -62,8 +62,8 @@ main (void)
test_perf_simple (0, 100000);
test_perf_simple (0, 1000000);
- test_perf_simple (LOG_UL_NODISCOVER, 100000);
- test_perf_simple (LOG_UL_NODISCOVER, 1000000);
+ test_perf_simple (LOG_UL_NOIMPLICIT, 100000);
+ test_perf_simple (LOG_UL_NOIMPLICIT, 1000000);
test_perf_simple (LOG_UL_NOTIME, 100000);
test_perf_simple (LOG_UL_NOTIME, 1000000);
diff --git a/t/test_umberlog.c b/t/test_umberlog.c
index 291bf43..9be5d08 100644
--- a/t/test_umberlog.c
+++ b/t/test_umberlog.c
@@ -115,7 +115,7 @@ START_TEST (test_ul_openlog_flag_ignore)
char *msg;
struct json_object *jo;
- ul_openlog ("umberlog/test_ul_openlog_flag_ignore", LOG_UL_NODISCOVER,
+ ul_openlog ("umberlog/test_ul_openlog_flag_ignore", LOG_UL_NOIMPLICIT,
LOG_LOCAL0);
msg = ul_format (LOG_DEBUG, "hello, I'm %s!", __FUNCTION__, NULL);
@@ -133,42 +133,19 @@ START_TEST (test_ul_openlog_flag_ignore)
}
END_TEST
-START_TEST (test_ul_set_log_flags)
+START_TEST (test_no_implicit)
{
char *msg;
struct json_object *jo;
- ul_openlog ("umberlog/test_ul_set_log_flags", 0, LOG_LOCAL0);
- ul_set_log_flags (LOG_UL_NODISCOVER);
+ ul_openlog ("umberlog/test_no_implicit", 0, LOG_LOCAL0);
+ ul_set_log_flags (LOG_UL_NOIMPLICIT);
msg = ul_format (LOG_DEBUG, "hello, I'm %s!", __FUNCTION__, NULL);
jo = parse_msg (msg);
free (msg);
- verify_value_missing (jo, "pid");
- verify_value_missing (jo, "uid");
- verify_value_missing (jo, "gid");
- verify_value_missing (jo, "host");
-
- json_object_put (jo);
-
- ul_closelog ();
-}
-END_TEST
-
-START_TEST (test_no_discover)
-{
- char *msg;
- struct json_object *jo;
-
- ul_openlog ("umberlog/test_no_discover", 0, LOG_LOCAL0);
- ul_set_log_flags (LOG_UL_NODISCOVER);
-
- msg = ul_format (LOG_DEBUG, "hello, I'm %s!", __FUNCTION__, NULL);
- jo = parse_msg (msg);
- free (msg);
-
- verify_value (jo, "msg", "hello, I'm test_no_discover!");
+ verify_value (jo, "msg", "hello, I'm test_no_implicit!");
verify_value_missing (jo, "facility");
verify_value_missing (jo, "priority");
verify_value_missing (jo, "program");
@@ -218,7 +195,7 @@ START_TEST (test_closelog)
struct json_object *jo;
ul_openlog ("umberlog/test_closelog", 0, LOG_LOCAL0);
- ul_set_log_flags (LOG_UL_NODISCOVER);
+ ul_set_log_flags (LOG_UL_NOIMPLICIT);
ul_closelog ();
msg = ul_format (LOG_DEBUG, "%s", __FUNCTION__, NULL);
@@ -263,9 +240,8 @@ main (void)
tcase_add_test (ft, test_overrides);
tcase_add_test (ft, test_ul_openlog);
tcase_add_test (ft, test_ul_openlog_flag_ignore);
- tcase_add_test (ft, test_ul_set_log_flags);
tcase_add_test (ft, test_closelog);
- tcase_add_test (ft, test_no_discover);
+ tcase_add_test (ft, test_no_implicit);
suite_add_tcase (s, ft);
sr = srunner_create (s);
diff --git a/t/test_umberlog_preload.c b/t/test_umberlog_preload.c
index d4db896..66f8aad 100644
--- a/t/test_umberlog_preload.c
+++ b/t/test_umberlog_preload.c
@@ -104,7 +104,7 @@ START_TEST (test_json_escape)
char *msg;
struct json_object *jo;
- openlog ("umberlog/test_json_escape", LOG_UL_NODISCOVER, LOG_LOCAL0);
+ openlog ("umberlog/test_json_escape", 0, LOG_LOCAL0);
msg = ul_format (LOG_DEBUG, "%s", __FUNCTION__,
"quotes", "Hi, \"quoted value\" speaking!",
@@ -153,7 +153,7 @@ START_TEST (test_positional_params)
char *msg;
struct json_object *jo;
- openlog ("umberlog/test_positional_params", LOG_UL_NOTIME, LOG_LOCAL0);
+ openlog ("umberlog/test_positional_params", 0, LOG_LOCAL0);
#define COMPLEX_FORMAT \
"%3$*5$.*2$hhd , %1$Lf , %4$.3s , %4$s", 1.0L, 5, (char)100, "prefix", -8
@@ -209,6 +209,36 @@ START_TEST (test_openlog_defaults)
}
END_TEST
+START_TEST (test_openlog_flags)
+{
+ char *msg;
+ struct json_object *jo;
+ char host[_POSIX_HOST_NAME_MAX + 1];
+
+ openlog ("umberlog/test_openlog_flags", LOG_UL_NOIMPLICIT, LOG_LOCAL0);
+
+ msg = ul_format (LOG_DEBUG, "hello, I'm %s!", __FUNCTION__, NULL);
+ jo = parse_msg (msg);
+ free (msg);
+
+ gethostname (host, _POSIX_HOST_NAME_MAX);
+
+ verify_value (jo, "msg", "hello, I'm test_openlog_flags!");
+ verify_value (jo, "facility", "local0");
+ verify_value (jo, "priority", "debug");
+ verify_value (jo, "program", "umberlog/test_openlog_flags");
+ verify_value_exists (jo, "pid");
+ verify_value_exists (jo, "uid");
+ verify_value_exists (jo, "gid");
+ verify_value_exists (jo, "timestamp");
+ verify_value (jo, "host", host);
+
+ json_object_put (jo);
+
+ closelog ();
+}
+END_TEST
+
int
main (void)
{
@@ -222,6 +252,7 @@ main (void)
ft = tcase_create ("Basic tests");
#if DEFAULT_DISCOVER_FLAGS == LOG_UL_ALL
tcase_add_test (ft, test_openlog_defaults);
+ tcase_add_test (ft, test_openlog_flags);
tcase_add_test (ft, test_simple);
tcase_add_test (ft, test_discover_priority);
#endif