fixed log compile errors

This commit is contained in:
git@daemon.de
2015-04-26 13:39:27 +02:00
parent c14bf4e41d
commit 6a4881f3d4
2 changed files with 12 additions and 5 deletions

16
log.c
View File

@@ -28,14 +28,20 @@ void verbose(const char * fmt, ...) {
char *msg = NULL; char *msg = NULL;
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
vasprintf(&msg, fmt, ap);
va_end(ap);
if(FORKED) { if(vasprintf(&msg, fmt, ap) >= 0) {
syslog(LOG_INFO, msg); va_end(ap);
if(FORKED) {
syslog(LOG_INFO, "%s", msg);
}
else {
fprintf(stderr, "%s", msg);
}
} }
else { else {
fprintf(stderr, msg); fprintf(stderr, "Fatal: could not store log message!\n");
exit(1);
} }
} }
} }

1
log.h
View File

@@ -23,6 +23,7 @@
#define _HAVE_LOG_H #define _HAVE_LOG_H
#define _WITH_DPRINTF #define _WITH_DPRINTF
#define _GNU_SOURCE
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>