]> git.ipfire.org Git - network.git/commitdiff
networkd: Add some very simple logging
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 29 Jan 2023 21:57:32 +0000 (21:57 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 29 Jan 2023 22:57:29 +0000 (22:57 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/networkd/daemon.c
src/networkd/logging.h [new file with mode: 0644]

index 40d900e203a68575e6f6258911233c5683da1902..abba6465a2bb657a0f725c1d53440e6191daebb4 100644 (file)
@@ -306,6 +306,7 @@ sbin_PROGRAMS += \
 dist_networkd_SOURCES = \
        src/networkd/daemon.c \
        src/networkd/daemon.h \
+       src/networkd/logging.h \
        src/networkd/main.c
 
 networkd_CPPFLAGS = \
index c6acefe25dfcc62d42c0dee594cb12d5332ef5ff..4d21bb660e88a1286043673551950037c83aaa2f 100644 (file)
@@ -23,6 +23,7 @@
 #include <systemd/sd-event.h>
 
 #include "daemon.h"
+#include "logging.h"
 
 struct nw_daemon {
        int nrefs;
@@ -37,14 +38,14 @@ static int nw_daemon_setup_loop(struct nw_daemon* daemon) {
        // Fetch a reference to the default event loop
        r = sd_event_default(&daemon->loop);
        if (r < 0) {
-               //ERROR("Could not setup event loop: %m\n");
+               ERROR("Could not setup event loop: %m\n");
                return 1;
        }
 
        // Enable the watchdog
        r = sd_event_set_watchdog(daemon->loop, 1);
        if (r < 0) {
-               //ERROR("Could not activate watchdog: %m\n");
+               ERROR("Could not activate watchdog: %m\n");
                return 1;
        }
 
@@ -118,7 +119,7 @@ int nw_daemon_run(struct nw_daemon* daemon) {
        // Launch the event loop
        r = sd_event_loop(daemon->loop);
        if (r) {
-               //ERROR("Could not run the event loop: %m\n");
+               ERROR("Could not run the event loop: %m\n");
                return r;
        }
 
diff --git a/src/networkd/logging.h b/src/networkd/logging.h
new file mode 100644 (file)
index 0000000..9d51f21
--- /dev/null
@@ -0,0 +1,32 @@
+/*#############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2023 IPFire Network Development Team                          #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#ifndef NETWORKD_LOGGING_H
+#define NETWORKD_LOGGING_H
+
+#include <stdio.h>
+
+/*
+       This is just something simple which will work for now...
+*/
+#define ERROR(...) fprintf(stderr, __VA_ARGS__)
+#define DEBUG(...) printf(__VA_ARGS__)
+
+#endif /* NETWORKD_LOGGING_H */