From 742d01a4f9a32f17561104ee7da8971c1bcdd703 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Wed, 8 Feb 2017 17:09:55 +0100 Subject: lib: Log to the logging system This removes the logfile and outputs log messages to the logging system. The creation of the logfiles (as well as the ap_init() call) were moved into ipcp_init() to simplify the IPCP creation and shutdown. Fixes #25 Fixes #27 --- src/lib/logs.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/lib/logs.c') 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 + * Sander Vrijders + * Dimitri Staessens * * 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 -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(); } -- cgit v1.2.3