aboutgitcodebugslistschat
path: root/util.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-03-18 07:49:08 +0100
committerStefano Brivio <sbrivio@redhat.com>2021-03-18 12:58:07 +0100
commit48ca38c6068bd15a94b1ecf2977d3f0160bbe63b (patch)
treeb15899a7dc87d400eabf56dcc67dc6f3b824addf /util.c
parent8bfcc9208cf99a653b9235bbe28ad5eb6c2e6bf2 (diff)
downloadpasst-48ca38c6068bd15a94b1ecf2977d3f0160bbe63b.tar
passt-48ca38c6068bd15a94b1ecf2977d3f0160bbe63b.tar.gz
passt-48ca38c6068bd15a94b1ecf2977d3f0160bbe63b.tar.bz2
passt-48ca38c6068bd15a94b1ecf2977d3f0160bbe63b.tar.lz
passt-48ca38c6068bd15a94b1ecf2977d3f0160bbe63b.tar.xz
passt-48ca38c6068bd15a94b1ecf2977d3f0160bbe63b.tar.zst
passt-48ca38c6068bd15a94b1ecf2977d3f0160bbe63b.zip
passt: Run in background, add message logging with severities
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'util.c')
-rw-r--r--util.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/util.c b/util.c
index 44357b7..7a75e02 100644
--- a/util.c
+++ b/util.c
@@ -21,9 +21,27 @@
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <sys/epoll.h>
+#include <syslog.h>
+#include <stdarg.h>
#include "passt.h"
+#define logfn(name, level) \
+void name(const char *format, ...) { \
+ va_list args; \
+ \
+ va_start(args, format); \
+ vsyslog(level, format, args); \
+ va_end(args); \
+}
+
+logfn(err, LOG_ERR)
+logfn(warn, LOG_WARNING)
+logfn(info, LOG_INFO)
+#ifdef DEBUG
+logfn(debug, LOG_DEBUG)
+#endif
+
/**
* csum_fold() - Fold long sum for IP and TCP checksum
* @sum: Original long sum