]> rtime.felk.cvut.cz Git - coffee/mt-apps.git/commitdiff
Log to syslog
authorMichal Sojka <michal.sojka@cvut.cz>
Wed, 8 Aug 2018 10:59:19 +0000 (12:59 +0200)
committerMichal Sojka <michal.sojka@cvut.cz>
Wed, 8 Aug 2018 10:59:19 +0000 (12:59 +0200)
mt_server.c

index 7abac686d71a0e64f117104955ddb5fd68d13729..c683c7528f1cdac93738b6868c3f40d5cd54b131 100644 (file)
@@ -1,6 +1,9 @@
+#define _GNU_SOURCE         /* See feature_test_macros(7) */
+#include <errno.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <syslog.h>
 
 #include "mt_server.h"
 #include "signal_exit.h"
@@ -245,6 +248,7 @@ static void fd_cb(EV_P_ ev_io *w_, int revents)
        mt_blank_wake();
 #endif
         *pos = 0;
+       syslog(LOG_INFO, w->text);
         char *line = new_line();
         if (line) {
             if (list_add(w->lines, w->text) == 0) {
@@ -269,6 +273,8 @@ int mt_server_init(mt_server_t *self, struct ev_loop *loop, int fd)
         return -1;
     }
 
+    openlog(program_invocation_short_name, LOG_PID | LOG_PERROR, LOG_DAEMON);
+
     memset(&info, 0, sizeof(info));
     info.port = HTTP_PORT;
     info.mounts = &mount;
@@ -308,6 +314,7 @@ void mt_server_deinit(mt_server_t *self)
     free_line(self->fd_watcher.text);
     list_deinit(self->fd_watcher.lines);
     lws_context_destroy(self->context);
+    closelog();
 }
 
 #ifndef NO_MAIN