From 453364e9f881e49f1572366cb6dc7b061a295c2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 26 Jan 2019 14:52:56 +0100 Subject: [PATCH] log: constructor/destructor to initialize/close syslog --- log.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/log.c b/log.c index c12a99e..ccb425e 100644 --- a/log.c +++ b/log.c @@ -6,6 +6,20 @@ #include #include +#include + +static void __attribute__((constructor)) +init(void) +{ + openlog(NULL, /*LOG_PID*/0, LOG_USER); +} + +static void __attribute__((destructor)) +fini(void) +{ + closelog(); +} + static void _log(enum log_class log_class, const char *module, const char *file, int lineno, const char *fmt, int sys_errno, va_list va)