aboutsummaryrefslogtreecommitdiff
path: root/log.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-04-28 12:43:17 +0000
committerOmar Polo <op@omarpolo.com>2021-04-28 12:43:17 +0000
commitd89a9060f812301850ae4c3f975d475e31fba0a7 (patch)
tree3886c0850acfe33f4115f08f7239a0000eeabf2e /log.c
parent42447f673f2bacb8b9038b17a7b6ba43a67b5cf7 (diff)
fatal: send log to logger
Diffstat (limited to 'log.c')
-rw-r--r--log.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/log.c b/log.c
index aa0d86d..82dcc31 100644
--- a/log.c
+++ b/log.c
@@ -53,24 +53,6 @@ print_date(void)
fprintf(stderr, "[%s] ", buf);
}
-void
-fatal(const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
-
- if (conf.foreground) {
- print_date();
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
- } else
- vsyslog(LOG_DAEMON | LOG_ERR, fmt, ap);
-
- va_end(ap);
- exit(1);
-}
-
static inline int
should_log(int priority)
{
@@ -97,6 +79,22 @@ send_log(int priority, const char *msg, size_t len)
imsg_flush(&logibuf);
}
+void
+fatal(const char *fmt, ...)
+{
+ va_list ap;
+ int r;
+ char *fmted;
+
+ va_start(ap, fmt);
+ if ((r = vasprintf(&fmted, fmt, ap)) != -1) {
+ send_log(LOG_ERR, fmted, r+1);
+ free(fmted);
+ }
+ va_end(ap);
+ exit(1);
+}
+
static inline void
vlog(int priority, struct client *c,
const char *fmt, va_list ap)