summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGergely Nagy <algernon@madhouse-project.org>2012-03-20 00:28:01 +0100
committerGergely Nagy <algernon@madhouse-project.org>2012-03-20 00:28:01 +0100
commit7ffd832758c8284bc95aecfc6d88705b80edab64 (patch)
treeb21230ca38d0f4961d9357da1296de8f0c4b4478 /lib
parent5d9a0c37bd042ba8450c5644af6484db51eca44e (diff)
downloadlibumberlog-7ffd832758c8284bc95aecfc6d88705b80edab64.tar.gz
libumberlog-7ffd832758c8284bc95aecfc6d88705b80edab64.tar.xz
libumberlog-7ffd832758c8284bc95aecfc6d88705b80edab64.zip
Implement LOG_CEE_NOCACHE & LOG_CEE_NODISCOVER handling
When LOG_CEE_NODISCOVER is set during openlog(), then don't do any discovery, not even when the value is cached. When _NOCACHE is set, then do not use the cached values for properties that can change during runtime, and their new value can be detected at runtime too. Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/cee-syslog.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/cee-syslog.c b/lib/cee-syslog.c
index 616684f..724372c 100644
--- a/lib/cee-syslog.c
+++ b/lib/cee-syslog.c
@@ -97,6 +97,15 @@ _find_prio (int prio)
return "<unknown>";
}
+static inline const pid_t
+_find_pid (void)
+{
+ if (cee_sys_settings.flags & LOG_CEE_NOCACHE)
+ return getpid ();
+ else
+ return cee_sys_settings.pid;
+}
+
static struct json_object *
_cee_json_vappend (struct json_object *json, va_list ap)
{
@@ -129,8 +138,11 @@ _cee_json_append (struct json_object *json, ...)
static inline void
_cee_discover (struct json_object *jo, int priority)
{
+ if (cee_sys_settings.flags & LOG_CEE_NODISCOVER)
+ return;
+
_cee_json_append (jo,
- "pid", "%d", cee_sys_settings.pid,
+ "pid", "%d", _find_pid (),
"facility", "%s", _find_facility (),
"priority", "%s", _find_prio (priority),
NULL);