util.c (684B)
1 /* See LICENSE file for copyright and license details. */ 2 #include <stdarg.h> 3 #include <stdio.h> 4 #include <stdlib.h> 5 #include <syslog.h> 6 #include "waffle.h" 7 8 void 9 loginfo(const char *fmt, ...) 10 { 11 va_list ap; 12 va_start(ap, fmt); 13 if (daemonize == 1) 14 vsyslog(LOG_INFO, fmt, ap); 15 else 16 vfprintf(stderr, fmt, ap); 17 va_end(ap); 18 } 19 20 void 21 logwarn(const char *fmt, ...) 22 { 23 va_list ap; 24 va_start(ap, fmt); 25 if (daemonize == 1) 26 vsyslog(LOG_WARNING, fmt, ap); 27 else 28 vfprintf(stderr, fmt, ap); 29 va_end(ap); 30 } 31 32 void 33 logerr(const char *fmt, ...) 34 { 35 va_list ap; 36 va_start(ap, fmt); 37 if (daemonize == 1) 38 vsyslog(LOG_ERR, fmt, ap); 39 else 40 vfprintf(stderr, fmt, ap); 41 va_end(ap); 42 exit(1); 43 }