summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 480d66b)
raw | patch | inline | side by side (parent: 480d66b)
author | Pierre-Yves Ritschard <pyr@spootnik.org> | |
Thu, 31 Jul 2014 13:12:38 +0000 (15:12 +0200) | ||
committer | Pierre-Yves Ritschard <pyr@spootnik.org> | |
Thu, 31 Jul 2014 13:12:38 +0000 (15:12 +0200) |
configure.ac | patch | blob | history | |
src/write_kafka.c | patch | blob | history |
diff --git a/configure.ac b/configure.ac
index 6e04af16b7b116a19f74d27e01d366162083366e..2a22c20af3650dee83c33537ff2748ed5fefa8cf 100644 (file)
--- a/configure.ac
+++ b/configure.ac
if test "x$with_librdkafka" = "xyes"
then
AC_CHECK_LIB(rdkafka, rd_kafka_new, [with_librdkafka="yes"], [with_librdkafka="no (Symbol 'rd_kafka_new' not found)"])
- AC_CHECK_LIB(rdkafka, rd_kafka_conf_set_log_cb, [with_librdkafka_log="yes"], [with_librdkafka_log="no (Symbol 'rd_kafka_conf_set_log_cb not found)"])
+ AC_CHECK_LIB(rdkafka, rd_kafka_conf_set_log_cb, [with_librdkafka_log_cb="yes"], [with_librdkafka_log_cb="no"])
+ AC_CHECK_LIB(rdkafka, rd_kafka_conf_set_logger, [with_librdkafka_logger="yes"], [with_librdkafka_logger="no"])
fi
if test "x$with_librdkafka" = "xyes"
then
AC_SUBST(BUILD_WITH_LIBRDKAFKA_LDFLAGS)
AC_SUBST(BUILD_WITH_LIBRDKAFKA_LIBS)
AC_DEFINE(HAVE_LIBRDKAFKA, 1, [Define if librdkafka is present and usable.])
- if test "x$with_librdkafka_log" = "xyes"
+ if test "x$with_librdkafka_log_cb" = "xyes"
then
- AC_DEFINE(HAVE_LIBRDKAFKA_LOG, 1, [Define if librdkafka log facility is present and usable.])
+ AC_DEFINE(HAVE_LIBRDKAFKA_LOG_CB, 1, [Define if librdkafka log facility is present and usable.])
+ fi
+ if test "x$with_librdkafka_logger" = "xyes"
+ then
+ AC_DEFINE(HAVE_LIBRDKAFKA_LOGGER, 1, [Define if librdkafka log facility is present and usable.])
fi
fi
CPPFLAGS="$SAVE_CPPFLAGS"
diff --git a/src/write_kafka.c b/src/write_kafka.c
index ff3176dd8dc3240a22733e1ba9019083a67ec243..2149ff1818a00d392069a93e00d5f7b85c1363e6 100644 (file)
--- a/src/write_kafka.c
+++ b/src/write_kafka.c
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,
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) {