45 #define WIN32_LEAN_AND_MEAN
47 #undef WIN32_LEAN_AND_MEAN
49 #include <sys/types.h>
50 #ifdef HAVE_SYS_TIME_H
53 #include <sys/_time.h>
65 static void _warn_helper(
int severity,
int log_errno,
const char *
fmt,
67 static void event_log(
int severity,
const char *
msg);
70 event_err(
int eval,
const char *
fmt, ...)
75 _warn_helper(_EVENT_LOG_ERR, errno, fmt, ap);
81 event_warn(
const char *
fmt, ...)
86 _warn_helper(_EVENT_LOG_WARN, errno, fmt, ap);
91 event_errx(
int eval,
const char *
fmt, ...)
96 _warn_helper(_EVENT_LOG_ERR, -1, fmt, ap);
102 event_warnx(
const char *
fmt, ...)
107 _warn_helper(_EVENT_LOG_WARN, -1, fmt, ap);
112 event_msgx(
const char *
fmt, ...)
117 _warn_helper(_EVENT_LOG_MSG, -1, fmt, ap);
122 _event_debugx(
const char *
fmt, ...)
127 _warn_helper(_EVENT_LOG_DEBUG, -1, fmt, ap);
132 _warn_helper(
int severity,
int log_errno,
const char *
fmt, va_list ap)
138 evutil_vsnprintf(buf,
sizeof(buf), fmt, ap);
142 if (log_errno >= 0) {
144 if (len <
sizeof(buf) - 3) {
145 evutil_snprintf(buf + len,
sizeof(buf) - len,
": %s",
146 strerror(log_errno));
150 event_log(severity, buf);
153 static event_log_cb log_fn = NULL;
162 event_log(
int severity,
const char *
msg)
165 log_fn(severity, msg);
167 const char *severity_str;
169 case _EVENT_LOG_DEBUG:
170 severity_str =
"debug";
173 severity_str =
"msg";
175 case _EVENT_LOG_WARN:
176 severity_str =
"warn";
179 severity_str =
"err";
182 severity_str =
"???";
185 (void)fprintf(stderr,
"[%s] %s\n", severity_str, msg);