From e496036b592c7c6d1bc419b5683a6a25bf46e193 Mon Sep 17 00:00:00 2001 From: Diego Santa Cruz Date: Wed, 9 Sep 2020 16:16:49 +0000 Subject: llmnrd: add command line option to log to syslog instead of stdio When llmnrd daemonizes stdout and stderr are redirected to /dev/null and all logs are lost. This adds a cli option -s / --syslog to send the logs to syslog instead. Signed-off-by: Diego Santa Cruz --- log.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'log.h') diff --git a/log.h b/log.h index 03b77dc..35c2f76 100644 --- a/log.h +++ b/log.h @@ -20,12 +20,19 @@ #define LOG_H #include +#include -#define log_err(fmt, args...) fprintf(stderr, "Error: " fmt, ##args) -#define log_warn(fmt, args...) fprintf(stderr, "Warning: " fmt, ##args) -#define log_info(fmt, args...) fprintf(stdout, fmt, ##args) +#include "compiler.h" + +void log_lvl(int lvl, const char *fmt, ...) __check_format_printf(2, 3); + +void log_to_syslog(void); + +#define log_err(fmt, args...) log_lvl(LOG_ERR, fmt, ##args) +#define log_warn(fmt, args...) log_lvl(LOG_WARNING, fmt, ##args) +#define log_info(fmt, args...) log_lvl(LOG_INFO, fmt, ##args) #ifdef DEBUG -# define log_dbg(fmt, args...) fprintf(stdout, fmt, ##args) +# define log_dbg(fmt, args...) log_lvl(LOG_DEBUG, fmt, ##args) #else # define log_dbg(fmt, args...) #endif -- cgit v1.2.3-54-g00ecf