X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fwrite_kafka.c;h=2149ff1818a00d392069a93e00d5f7b85c1363e6;hb=19d5c74dca00487c35b4e103f0d11e2a0d74012e;hp=ff3176dd8dc3240a22733e1ba9019083a67ec243;hpb=480d66bbe1970d6cbb68765878f2ee6187bbd5b2;p=collectd.git diff --git a/src/write_kafka.c b/src/write_kafka.c index ff3176dd..2149ff18 100644 --- a/src/write_kafka.c +++ b/src/write_kafka.c @@ -61,7 +61,6 @@ static int kafka_write(const data_set_t *, const value_list_t *, user_data_t *); static int32_t kafka_partition(const rd_kafka_topic_t *, const void *, size_t, int32_t, void *, void *); -#ifdef HAVE_LIBRDKAFKA_LOG static void kafka_log(const rd_kafka_t *, int, const char *, const char *); static void kafka_log(const rd_kafka_t *rkt, int level, @@ -70,8 +69,6 @@ static void kafka_log(const rd_kafka_t *rkt, int level, plugin_log(level, "%s", msg); } -#endif - static int32_t kafka_partition(const rd_kafka_topic_t *rkt, const void *keydata, size_t keylen, int32_t partition_cnt, void *p, void *m) @@ -186,10 +183,7 @@ static void kafka_config_topic(rd_kafka_conf_t *conf, oconfig_item_t *ci) /* {{{ tctx->store_rates = 1; tctx->format = KAFKA_FORMAT_JSON; -#ifdef HAVE_LIBRDKAFKA_LOG - /* - * Some versions of rdkafka do not allow setting a log callback. - */ +#ifdef HAVE_LIBRDKAFKA_LOG_CB rd_kafka_conf_set_log_cb(conf, kafka_log); #endif if ((tctx->kafka = rd_kafka_new(RD_KAFKA_PRODUCER, conf, @@ -198,6 +192,9 @@ static void kafka_config_topic(rd_kafka_conf_t *conf, oconfig_item_t *ci) /* {{{ ERROR("write_kafka plugin: cannot create kafka handle."); return; } +#ifdef HAVE_LIBRDKAFKA_LOGGER + rd_kafka_conf_set_logger(tctx->kafka, kafka_log); +#endif conf = NULL; if ((tctx->conf = rd_kafka_topic_conf_new()) == NULL) {