aboutgitcodebugslistschat
path: root/log.h
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2023-10-13 15:50:28 +1100
committerStefano Brivio <sbrivio@redhat.com>2023-11-07 09:54:53 +0100
commit50d46ec847492dbcf6f0b15221188ad439d5e572 (patch)
treed460bb7809b012e6636a3f8e13c1ab4ad209b59a /log.h
parent0ad54e104338e29dc271f198d4cca037405ac8d0 (diff)
downloadpasst-50d46ec847492dbcf6f0b15221188ad439d5e572.tar
passt-50d46ec847492dbcf6f0b15221188ad439d5e572.tar.gz
passt-50d46ec847492dbcf6f0b15221188ad439d5e572.tar.bz2
passt-50d46ec847492dbcf6f0b15221188ad439d5e572.tar.lz
passt-50d46ec847492dbcf6f0b15221188ad439d5e572.tar.xz
passt-50d46ec847492dbcf6f0b15221188ad439d5e572.tar.zst
passt-50d46ec847492dbcf6f0b15221188ad439d5e572.zip
log: Don't define logging function 4 times
In log.c we use a macro to define logging functions for each of 4 priority levels. The only difference between these is the priority we pass to vsyslog() and similar functions. Because it's done as a macro, however, the entire functions code is included in the binary 4 times. Rearrange this to take the priority level as a parameter to a regular function, then just use macros to define trivial wrappers which pass the priority level. This saves about 600 bytes of text in the executable (x86, non-AVX2). Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'log.h')
-rw-r--r--log.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/log.h b/log.h
index a17171a..b4fb7e9 100644
--- a/log.h
+++ b/log.h
@@ -6,14 +6,18 @@
#ifndef LOG_H
#define LOG_H
+#include <syslog.h>
+
#define LOGFILE_SIZE_DEFAULT (1024 * 1024UL)
#define LOGFILE_CUT_RATIO 30 /* When full, cut ~30% size */
#define LOGFILE_SIZE_MIN (5UL * MAX(BUFSIZ, PAGE_SIZE))
-void err(const char *format, ...);
-void warn(const char *format, ...);
-void info(const char *format, ...);
-void debug(const char *format, ...);
+void logmsg(int pri, const char *format, ...);
+
+#define err(...) logmsg(LOG_ERR, __VA_ARGS__)
+#define warn(...) logmsg(LOG_WARNING, __VA_ARGS__)
+#define info(...) logmsg(LOG_INFO, __VA_ARGS__)
+#define debug(...) logmsg(LOG_DEBUG, __VA_ARGS__)
#define die(...) \
do { \