diff options
author | Omar Polo <op@omarpolo.com> | 2021-04-28 12:43:17 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2021-04-28 12:43:17 +0000 |
commit | d89a9060f812301850ae4c3f975d475e31fba0a7 (patch) | |
tree | 3886c0850acfe33f4115f08f7239a0000eeabf2e /log.c | |
parent | 42447f673f2bacb8b9038b17a7b6ba43a67b5cf7 (diff) |
fatal: send log to logger
Diffstat (limited to 'log.c')
-rw-r--r-- | log.c | 34 |
1 files changed, 16 insertions, 18 deletions
@@ -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) |