Commit Diff


commit - 42447f673f2bacb8b9038b17a7b6ba43a67b5cf7
commit + d89a9060f812301850ae4c3f975d475e31fba0a7
blob - aa0d86da2382286d89826dd57e8dd7556e25c02c
blob + 82dcc3165b147d9811541350bccda79e6a85e3bf
--- log.c
+++ log.c
@@ -51,24 +51,6 @@ print_date(void)
 	strftime(buf, sizeof(buf), "%F %T",
 	    localtime_r(&t, &tminfo));
 	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
@@ -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)