Coder Social home page Coder Social logo

Comments (7)

mfontanini avatar mfontanini commented on June 1, 2024

Good catch, I didn't notice that one. Sounds like a good idea! There's no logging strategy at this point. At some point I wanted to use rdkafka's logging as it already exists but it's not exposed publicly, which kind of sucks. I guess for now just catching that would work.

from cppkafka.

Cfretz244 avatar Cfretz244 commented on June 1, 2024

Oh yeah, it would be great if it could tap into the existing logging.
Personally, I've never been a big fan of libraries logging in the first place, but there are situations like this where it's really the only viable response.

from cppkafka.

mfontanini avatar mfontanini commented on June 1, 2024

I think cppkafka could actually log through rdkafka via the configured log callback or rd_kafka_log_print (the default) in case there's none. Reopening so I don't forget about this one.

from cppkafka.

arvidn avatar arvidn commented on June 1, 2024

One way to make it possible for a client to detect these kinds of errors would be to expose close() to the public, which can then throw. But yes, the destructor should be assumed to be called while unwinding because of another exception.

from cppkafka.

accelerated avatar accelerated commented on June 1, 2024

Would this work? Not sure about the facility name...I used LOG_USER

Consumer::~Consumer() {
    try {
        // make sure to destroy the function closures. in case they hold kafka
        // objects, they will need to be destroyed before we destroy the handle
        assignment_callback_ = nullptr;
        revocation_callback_ = nullptr;
        rebalance_error_callback_ = nullptr;
        close();
    }
    catch (const Exception& ex) {
        auto& callback = get_configuration().get_log_callback();
        if (callback) {
            callback(*this, LOG_ERR, "user", ex.what());
        }
        else {
            rd_kafka_log_print(get_handle(), LOG_ERR, "user", ex.what());
        }
    }
}

from cppkafka.

mfontanini avatar mfontanini commented on June 1, 2024

lol at "Reopening so I don't forget about this one.".

That looks good. I would probably change "user" to "cppkafka" so it's clear where the error is coming from.

from cppkafka.

accelerated avatar accelerated commented on June 1, 2024

Maybe this should be closed now...

from cppkafka.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.