Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

librdkafka 0.8 logger callback error #15

Closed
zbweng opened this issue Aug 8, 2013 · 4 comments
Closed

librdkafka 0.8 logger callback error #15

zbweng opened this issue Aug 8, 2013 · 4 comments
Assignees
Milestone

Comments

@zbweng
Copy link

zbweng commented Aug 8, 2013

Hi, Magnus.
librdkafka 0.8 provides a callback for logger. The comment of function "rd_kafka_set_logger" mentions that "Alternatively the application may provide its own logger callback".
However, when I provide my logger callback, some compiler errors occur.

error: invalid use of incomplete type ‘const rd_kafka_t {aka const struct rd_kafka_s}’
/usr/local/include/librdkafka/rdkafka.h:59:16: error: forward declaration of ‘const rd_kafka_t {aka const struct rd_kafka_s}’

I wonder whether I use logger callback correctly.

Thanks.

@ghost ghost assigned edenhill Aug 8, 2013
@edenhill
Copy link
Contributor

edenhill commented Aug 9, 2013

I cant reproduce this issue, could you provide the relevant parts of your code?

This works for me:

#include <librdkafka/rdkafka.h>
...
static void logger (const rd_kafka_t *rk, int level,
const char *fac, const char *buf) {
fprintf(stderr, "RDKAFKA-%i-%s: %s: %s\n",
level, fac, rd_kafka_name(rk), buf);
}

....

int main (...) {
...
rk = rd_kafka_new(....);
rd_kafka_set_logger(rk, logger);
...

@zbweng
Copy link
Author

zbweng commented Aug 10, 2013

Hi, Magnus.
Thank you for your reply.

I find that I used "rk->rk_name" in my c++ code. This causes the compilation error above since the compiler could not find the definition of "rd_kafka_t". What a stupid mistake!
When I use "rd_kafka_name(const_cast<rd_kafka_t *>(rk))" instead, the compilation error disappears.

@zbweng zbweng closed this as completed Aug 10, 2013
@zbweng zbweng reopened this Aug 10, 2013
@edenhill
Copy link
Contributor

Did you mean to reopen this issue?

@zbweng
Copy link
Author

zbweng commented Aug 10, 2013

No. Actually, I am new to Github. This is a misoperation. I hope you don't mind. :)
Thank you for solving my problem.

@zbweng zbweng closed this as completed Aug 10, 2013
@winbatch winbatch mentioned this issue Feb 11, 2014
kwdubuc pushed a commit to SolaceDev/librdkafka that referenced this issue Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants