summaryrefslogtreecommitdiffstats
path: root/ldpd/log.h
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2024-01-25 22:54:54 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2024-03-10 12:42:14 +0100
commit95a737ed1bf7f89cb8e5367ef8e8e66a800084d7 (patch)
tree9c637ac3cc463ed198f6dbd81578bbb90bb57d07 /ldpd/log.h
parentlib: allow recirculating/relaying log messages (diff)
downloadfrr-95a737ed1bf7f89cb8e5367ef8e8e66a800084d7.tar.xz
frr-95a737ed1bf7f89cb8e5367ef8e8e66a800084d7.zip
ldpd: use zlog recirculation for subprocesses
This way, full functionality of `zlog_*` is available. Having `fatal()` be wrappers around `assertf()` also means we get backtraces, which is not the case for a plain `exit(1)`. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'ldpd/log.h')
-rw-r--r--ldpd/log.h43
1 files changed, 22 insertions, 21 deletions
diff --git a/ldpd/log.h b/ldpd/log.h
index 641ad8ac5..aa6f70060 100644
--- a/ldpd/log.h
+++ b/ldpd/log.h
@@ -8,29 +8,30 @@
#ifndef LOG_H
#define LOG_H
-#include <stdarg.h>
+#include "log.h"
+#include "assert.h"
extern const char *log_procname;
-void logit(int, const char *, ...)
- __attribute__((__format__ (printf, 2, 3)));
-void vlog(int, const char *, va_list)
- __attribute__((__format__ (printf, 2, 0)));
-void log_warn(const char *, ...)
- __attribute__((__format__ (printf, 1, 2)));
-void log_warnx(const char *, ...)
- __attribute__((__format__ (printf, 1, 2)));
-void log_info(const char *, ...)
- __attribute__((__format__ (printf, 1, 2)));
-void log_notice(const char *, ...)
- __attribute__((__format__ (printf, 1, 2)));
-void log_debug(const char *, ...)
- __attribute__((__format__ (printf, 1, 2)));
-void fatal(const char *)
- __attribute__ ((noreturn))
- __attribute__((__format__ (printf, 1, 0)));
-void fatalx(const char *)
- __attribute__ ((noreturn))
- __attribute__((__format__ (printf, 1, 0)));
+#define log_warnx zlog_err /* yes this is poorly named */
+#define log_warn zlog_warn
+#define log_info zlog_info
+#define log_notice zlog_notice /* not used anywhere */
+#define log_debug zlog_debug
+
+#define fatal(msg) \
+ do { \
+ assertf(0, "fatal in %s: %pSQq (%m)", log_procname, \
+ (const char *)msg); \
+ __builtin_unreachable(); \
+ } while (0) \
+ /* end */
+#define fatalx(msg) \
+ do { \
+ assertf(0, "fatal in %s: %pSQq", log_procname, \
+ (const char *)msg); \
+ __builtin_unreachable(); \
+ } while (0) \
+ /* end */
#endif /* LOG_H */