}
/* }}} */
+static void prom_logger(__attribute__((unused)) void *arg, char const *fmt,
+ va_list ap) {
+ /* {{{ */
+ char errbuf[1024];
+ vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
+
+ ERROR("write_prometheus plugin: %s", errbuf);
+} /* }}} prom_logger */
+
#if MHD_VERSION >= 0x00090000
static int prom_open_socket(int addrfamily) {
/* {{{ */
return NULL;
}
- struct MHD_Daemon *d =
- MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION, 0,
- /* MHD_AcceptPolicyCallback = */ NULL,
- /* MHD_AcceptPolicyCallback arg = */ NULL, http_handler,
- NULL, MHD_OPTION_LISTEN_SOCKET, fd, MHD_OPTION_END);
+ struct MHD_Daemon *d = MHD_start_daemon(
+ MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, 0,
+ /* MHD_AcceptPolicyCallback = */ NULL,
+ /* MHD_AcceptPolicyCallback arg = */ NULL, http_handler, NULL,
+ MHD_OPTION_LISTEN_SOCKET, fd, MHD_OPTION_EXTERNAL_LOGGER, prom_logger,
+ NULL, MHD_OPTION_END);
if (d == NULL) {
ERROR("write_prometheus plugin: MHD_start_daemon() failed.");
close(fd);
#else /* if MHD_VERSION < 0x00090000 */
static struct MHD_Daemon *prom_start_daemon() {
/* {{{ */
- struct MHD_Daemon *d =
- MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION, 0,
- /* MHD_AcceptPolicyCallback = */ NULL,
- /* MHD_AcceptPolicyCallback arg = */ NULL, http_handler,
- NULL, MHD_OPTION_END);
+ struct MHD_Daemon *d = MHD_start_daemon(
+ MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, 0,
+ /* MHD_AcceptPolicyCallback = */ NULL,
+ /* MHD_AcceptPolicyCallback arg = */ NULL, http_handler, NULL,
+ MHD_OPTION_EXTERNAL_LOGGER, prom_logger, NULL, MHD_OPTION_END);
if (d == NULL) {
ERROR("write_prometheus plugin: MHD_start_daemon() failed.");
return NULL;