#include <netinet/in6.h>
#endif
-#define EVDNS_LOG_DEBUG 0
-#define EVDNS_LOG_WARN 1
-#define EVDNS_LOG_MSG 2
+#define EVDNS_LOG_DEBUG EVENT_LOG_DEBUG
+#define EVDNS_LOG_WARN EVENT_LOG_WARN
+#define EVDNS_LOG_MSG EVENT_LOG_MSG
#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX 255
EVLOCK_ASSERT_LOCKED((base)->lock)
#endif
-static void
-default_evdns_log_fn(int warning, const char *buf)
-{
- if (warning == EVDNS_LOG_WARN)
- event_warnx("[evdns] %s", buf);
- else if (warning == EVDNS_LOG_MSG)
- event_msgx("[evdns] %s", buf);
- else
- event_debug(("[evdns] %s", buf));
-}
-
static evdns_debug_log_fn_type evdns_log_fn = NULL;
void
#define EVDNS_LOG_CHECK
#endif
-static void evdns_log_(int warn, const char *fmt, ...) EVDNS_LOG_CHECK;
+static void evdns_log_(int severity, const char *fmt, ...) EVDNS_LOG_CHECK;
static void
-evdns_log_(int warn, const char *fmt, ...)
+evdns_log_(int severity, const char *fmt, ...)
{
va_list args;
- char buf[512];
- if (!evdns_log_fn)
- return;
va_start(args,fmt);
- evutil_vsnprintf(buf, sizeof(buf), fmt, args);
- va_end(args);
if (evdns_log_fn) {
- if (warn == EVDNS_LOG_MSG)
- warn = EVDNS_LOG_WARN;
- evdns_log_fn(warn, buf);
+ char buf[512];
+ int is_warn = (severity == EVDNS_LOG_WARN);
+ evutil_vsnprintf(buf, sizeof(buf), fmt, args);
+ evdns_log_fn(is_warn, buf);
} else {
- default_evdns_log_fn(warn, buf);
+ event_logv_(severity, NULL, fmt, args);
}
-
+ va_end(args);
}
#define log evdns_log_
void event_msgx(const char *fmt, ...) EV_CHECK_FMT(1,2);
void event_debugx_(const char *fmt, ...) EV_CHECK_FMT(1,2);
+void event_logv_(int severity, const char *errstr, const char *fmt, va_list ap)
+ EV_CHECK_FMT(3,0);
+
#ifdef EVENT_DEBUG_LOGGING_ENABLED
#define event_debug(x) do { \
if (event_debug_get_logging_mask_()) { \
#include "log-internal.h"
-static void warn_helper_(int severity, const char *errstr, const char *fmt,
- va_list ap);
static void event_log(int severity, const char *msg);
static void event_exit(int errcode) EV_NORETURN;
va_list ap;
va_start(ap, fmt);
- warn_helper_(EVENT_LOG_ERR, strerror(errno), fmt, ap);
+ event_logv_(EVENT_LOG_ERR, strerror(errno), fmt, ap);
va_end(ap);
event_exit(eval);
}
va_list ap;
va_start(ap, fmt);
- warn_helper_(EVENT_LOG_WARN, strerror(errno), fmt, ap);
+ event_logv_(EVENT_LOG_WARN, strerror(errno), fmt, ap);
va_end(ap);
}
int err = evutil_socket_geterror(sock);
va_start(ap, fmt);
- warn_helper_(EVENT_LOG_ERR, evutil_socket_error_to_string(err), fmt, ap);
+ event_logv_(EVENT_LOG_ERR, evutil_socket_error_to_string(err), fmt, ap);
va_end(ap);
event_exit(eval);
}
int err = evutil_socket_geterror(sock);
va_start(ap, fmt);
- warn_helper_(EVENT_LOG_WARN, evutil_socket_error_to_string(err), fmt, ap);
+ event_logv_(EVENT_LOG_WARN, evutil_socket_error_to_string(err), fmt, ap);
va_end(ap);
}
va_list ap;
va_start(ap, fmt);
- warn_helper_(EVENT_LOG_ERR, NULL, fmt, ap);
+ event_logv_(EVENT_LOG_ERR, NULL, fmt, ap);
va_end(ap);
event_exit(eval);
}
va_list ap;
va_start(ap, fmt);
- warn_helper_(EVENT_LOG_WARN, NULL, fmt, ap);
+ event_logv_(EVENT_LOG_WARN, NULL, fmt, ap);
va_end(ap);
}
va_list ap;
va_start(ap, fmt);
- warn_helper_(EVENT_LOG_MSG, NULL, fmt, ap);
+ event_logv_(EVENT_LOG_MSG, NULL, fmt, ap);
va_end(ap);
}
va_list ap;
va_start(ap, fmt);
- warn_helper_(EVENT_LOG_DEBUG, NULL, fmt, ap);
+ event_logv_(EVENT_LOG_DEBUG, NULL, fmt, ap);
va_end(ap);
}
-static void
-warn_helper_(int severity, const char *errstr, const char *fmt, va_list ap)
+void
+event_logv_(int severity, const char *errstr, const char *fmt, va_list ap)
{
char buf[1024];
size_t len;
+ if (severity == EVENT_LOG_DEBUG && !event_debug_get_logging_mask_())
+ return;
+
if (fmt != NULL)
evutil_vsnprintf(buf, sizeof(buf), fmt, ap);
else
{ "search", dns_search_test, TT_FORK|TT_NEED_BASE, &basic_setup, NULL },
{ "search_cancel", dns_search_cancel_test,
TT_FORK|TT_NEED_BASE, &basic_setup, NULL },
- { "retry", dns_retry_test, TT_FORK|TT_NEED_BASE, &basic_setup, NULL },
- { "reissue", dns_reissue_test, TT_FORK|TT_NEED_BASE, &basic_setup, NULL },
+ { "retry", dns_retry_test, TT_FORK|TT_NEED_BASE|TT_NO_LOGS, &basic_setup, NULL },
+ { "reissue", dns_reissue_test, TT_FORK|TT_NEED_BASE|TT_NO_LOGS, &basic_setup, NULL },
{ "inflight", dns_inflight_test, TT_FORK|TT_NEED_BASE, &basic_setup, NULL },
{ "bufferevent_connect_hostname", test_bufferevent_connect_hostname,
TT_FORK|TT_NEED_BASE, &basic_setup, NULL },