From: Florian Forster Date: Tue, 10 Oct 2017 20:38:05 +0000 (+0200) Subject: write_prometheus plugin: Implement logging callback. X-Git-Tag: collectd-5.8.0~1^2~10 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=c7fa5db74dc5ba0d8ace1149caaa545f4891bb47;p=collectd.git write_prometheus plugin: Implement logging callback. --- diff --git a/src/write_prometheus.c b/src/write_prometheus.c index 56a3174b..68ec4e43 100644 --- a/src/write_prometheus.c +++ b/src/write_prometheus.c @@ -731,6 +731,15 @@ metric_family_get(data_set_t const *ds, value_list_t const *vl, size_t ds_index, } /* }}} */ +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) { /* {{{ */ @@ -785,11 +794,12 @@ static struct MHD_Daemon *prom_start_daemon() { 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); @@ -801,11 +811,11 @@ static struct MHD_Daemon *prom_start_daemon() { #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;