diff options
author | Sander Vrijders <[email protected]> | 2017-02-08 17:07:45 +0000 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2017-02-08 17:07:45 +0000 |
commit | 6ade491f770904d8244863904359c449b5aeb5f7 (patch) | |
tree | 26a9c0b622b5bf875b783692837d1069799f8fcc /src/lib | |
parent | 9117f7f6fec70f2da24e8e77256747d11d67bf8d (diff) | |
parent | 742d01a4f9a32f17561104ee7da8971c1bcdd703 (diff) | |
download | ouroboros-6ade491f770904d8244863904359c449b5aeb5f7.tar.gz ouroboros-6ade491f770904d8244863904359c449b5aeb5f7.zip |
Merged in dstaesse/ouroboros/be-syslog (pull request #364)
lib: Log to the logging system
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/bitmap.c | 3 | ||||
-rw-r--r-- | src/lib/irm.c | 8 | ||||
-rw-r--r-- | src/lib/logs.c | 20 |
3 files changed, 12 insertions, 19 deletions
diff --git a/src/lib/bitmap.c b/src/lib/bitmap.c index 5905dfee..255f2b4d 100644 --- a/src/lib/bitmap.c +++ b/src/lib/bitmap.c @@ -21,10 +21,7 @@ * 02110-1301 USA */ -#define OUROBOROS_PREFIX "bitmap" - #include <ouroboros/bitmap.h> -#include <ouroboros/logs.h> #include <assert.h> #include <stdlib.h> #include <string.h> diff --git a/src/lib/irm.c b/src/lib/irm.c index 8b312833..477547a2 100644 --- a/src/lib/irm.c +++ b/src/lib/irm.c @@ -20,13 +20,10 @@ * 02110-1301 USA */ -#define OUROBOROS_PREFIX "libouroboros-irm" - #include <ouroboros/config.h> #include <ouroboros/errno.h> #include <ouroboros/irm.h> #include <ouroboros/utils.h> -#include <ouroboros/logs.h> #include <ouroboros/sockets.h> #include <stdbool.h> @@ -220,10 +217,9 @@ int irm_enroll_ipcp(pid_t api, msg.api = api; msg.n_dif_name = 1; msg.dif_name = malloc(sizeof(*(msg.dif_name))); - if (msg.dif_name == NULL) { - LOG_ERR("Failed to malloc"); + if (msg.dif_name == NULL) return -ENOMEM; - } + msg.dif_name[0] = dif_name; recv_msg = send_recv_irm_msg(&msg); diff --git a/src/lib/logs.c b/src/lib/logs.c index 449ee191..3184773f 100644 --- a/src/lib/logs.c +++ b/src/lib/logs.c @@ -3,7 +3,8 @@ * * Logging facilities * - * Sander Vrijders <[email protected]> + * Sander Vrijders <[email protected]> + * Dimitri Staessens <[email protected]> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -24,19 +25,18 @@ #include <ouroboros/logs.h> -FILE * logfile = NULL; +bool log_syslog; -int set_logfile(char * filename) +void log_init(bool sysout) { - logfile = fopen(filename, "w"); - if (logfile == NULL) - return -1; + log_syslog = sysout; - return 0; + if (log_syslog) + openlog(NULL, LOG_PID, LOG_DAEMON); } -void close_logfile() +void log_fini(void) { - if (logfile != NULL) - fclose(logfile); + if (log_syslog) + closelog(); } |