RdKafka\Conf::setLogCb

(PECL rdkafka >= 4.0.0, librdkafka >= 0.9.4)

RdKafka\Conf::setLogCbSet log callback

Description

public RdKafka\Conf::setLogCb(callable $callback): void

Set log callback. You will get events according to log_level that was set in RdKafka\Conf

Note:

To ensure that logs are received by the callback, it is required to call RdKafka::poll() at regular intervals. RdKafka::flush() must be called before the instance is destroyed, otherwise outstanding log messages may be silently discarded.

Note:

HINT: The extension takes care of setting log.queue to true in RdKafka\Conf which is needed for this.

Parameters

callback (callable)

A callable with the following signature:

<?php
/**
 * @param object $kafka
 * @param int $level
 * @param string $facility
 * @param string $message
 */
function ($kafka, $level, $facility, $message);

Return Values

Returns no value.

Examples

Example #1 RdKafka\Conf::setLogCb() example

<?php
$conf->setLogCb(function ($kafka, $level, $facility, $message) {
    printf("Kafka %s: %s (level: %d)\n", $facility, $message, $level);
});
?>