mirror of https://github.com/omar-polo/gmid.git
fatal: send log to logger
This commit is contained in:
parent
42447f673f
commit
d89a9060f8
34
log.c
34
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)
|
||||
|
|
Loading…
Reference in New Issue