+#define __log(Level, Fmt, ...) \
+ if (log_level >= Level) { \
+ syslog(Level, Fmt, ##__VA_ARGS__); \
+ }
+
+#define debug(Fmt, ...) __log(LOG_DEBUG, Fmt, ##__VA_ARGS__)
+#define notice(Fmt, ...) __log(LOG_NOTICE, Fmt, ##__VA_ARGS__)
+#define info(Fmt, ...) __log(LOG_INFO, Fmt, ##__VA_ARGS__)
+#define warn(Fmt, ...) __log(LOG_WARNING, Fmt, ##__VA_ARGS__)
+#define err(Fmt, ...) __log(LOG_ERR, Fmt, ##__VA_ARGS__)
+#define crit(Fmt, ...) __log(LOG_CRIT, Fmt, ##__VA_ARGS__)
+#define alert(Fmt, ...) __log(LOG_ALERT, Fmt, ##__VA_ARGS__)
+#define emerg(Fmt, ...) __log(LOG_ALERT, Fmt, ##__VA_ARGS__)
+
+#define UNIXERR(fun) err("%s:%d:%s %s: %m", \
+ __FILE__, __LINE__, __func__, fun)
+