src/rdkafka_broker.c
void rd_kafka_broker_conn_closed (rd_kafka_broker_t *rkb,
                                  rd_kafka_resp_err_t err,
                                  const char *errstr) {
        int log_level = LOG_ERR;

        if (!rkb->rkb_rk->rk_conf.log_connection_close) {
                /* Silence all connection closes */
                log_level = LOG_DEBUG;

        } else {
                /* Silence close logs for connections that are idle,
                 * it is most likely the broker's idle connection
                 * reaper kicking in.
                 *
                 * Indications there might be an error and not an
                 * idle disconnect:
                 *  - If the connection age is low a disconnect
                 *    typically indicates a failure, such as protocol mismatch.
                 *  - If the connection hasn't been idle long enough.
                 *  - There are outstanding requests, or requests enqueued.
                 *
                 * For non-idle connections, adjust log level:
                 *  - requests in-flight: LOG_WARNING
                 *  - else: LOG_INFO
                 */
                rd_ts_t now = rd_clock();
                rd_ts_t minidle =
                        RD_MAX(60*1000/*60s*/,
                               rkb->rkb_rk->rk_conf.socket_timeout_ms) * 1000;
                int inflight = rd_kafka_bufq_cnt(&rkb->rkb_waitresps);
                int inqueue = rd_kafka_bufq_cnt(&rkb->rkb_outbufs);

                if (rkb->rkb_ts_state + minidle < now &&
                    rkb->rkb_ts_tx_last + minidle < now &&
                    inflight + inqueue == 0)
                        log_level = LOG_DEBUG;
                else if (inflight > 1)
                        log_level = LOG_WARNING;
                else
                        log_level = LOG_INFO;
        }

        rd_kafka_broker_fail(rkb, log_level, err, "%s", errstr);
}
/**
 * @brief Handle broker connection close.
 *
 * @locality broker thread
 */
@brief Handle broker connection close.
@locality broker thread
@brief Handle broker connection close . @locality broker thread
void rd_kafka_broker_conn_closed (rd_kafka_broker_t *rkb,
                                  rd_kafka_resp_err_t err,
                                  const char *errstr) {
        int log_level = LOG_ERR;
        if (!rkb->rkb_rk->rk_conf.log_connection_close) {
                log_level = LOG_DEBUG;
        } else {
                rd_ts_t now = rd_clock();
                rd_ts_t minidle =
                        RD_MAX(60*1000,
                               rkb->rkb_rk->rk_conf.socket_timeout_ms) * 1000;
                int inflight = rd_kafka_bufq_cnt(&rkb->rkb_waitresps);
                int inqueue = rd_kafka_bufq_cnt(&rkb->rkb_outbufs);
                if (rkb->rkb_ts_state + minidle < now &&
                    rkb->rkb_ts_tx_last + minidle < now &&
                    inflight + inqueue == 0)
                        log_level = LOG_DEBUG;
                else if (inflight > 1)
                        log_level = LOG_WARNING;
                else
                        log_level = LOG_INFO;
        }
        rd_kafka_broker_fail(rkb, log_level, err, "%s", errstr);
}
void rd_kafka_broker_conn_closed ( rd_kafka_broker_t * rkb , rd_kafka_resp_err_t err , const char * errstr ) { int log_level = LOG_ERR ; if ( ! rkb -> rkb_rk -> rk_conf . log_connection_close ) { log_level = LOG_DEBUG ; } else { rd_ts_t now = rd_clock ( ) ; rd_ts_t minidle = RD_MAX ( 60 * 1000 , rkb -> rkb_rk -> rk_conf . socket_timeout_ms ) * 1000 ; int inflight = rd_kafka_bufq_cnt ( & rkb -> rkb_waitresps ) ; int inqueue = rd_kafka_bufq_cnt ( & rkb -> rkb_outbufs ) ; if ( rkb -> rkb_ts_state + minidle < now && rkb -> rkb_ts_tx_last + minidle < now && inflight + inqueue == 0 ) log_level = LOG_DEBUG ; else if ( inflight > 1 ) log_level = LOG_WARNING ; else log_level = LOG_INFO ; } rd_kafka_broker_fail ( rkb , log_level , err , " " , errstr ) ; }
@brief Handle broker connection close.
@brief Handle broker connection close .
/* Silence all connection closes */ /* Silence close logs for connections that are idle,
                 * it is most likely the broker's idle connection
                 * reaper kicking in.
                 *
                 * Indications there might be an error and not an
                 * idle disconnect:
                 *  - If the connection age is low a disconnect
                 *    typically indicates a failure, such as protocol mismatch.
                 *  - If the connection hasn't been idle long enough.
                 *  - There are outstanding requests, or requests enqueued.
                 *
                 * For non-idle connections, adjust log level:
                 *  - requests in-flight: LOG_WARNING
                 *  - else: LOG_INFO
                 */ /*60s*/