Skip to content

Conversation

@imalexoff
Copy link

@imalexoff imalexoff commented Sep 26, 2025

Description

Added a log handler to prevent writing to stderr for the producer, consumer and admin client. Also added mapping of SyslogLevel to the corresponding LogHandler level.

Fixes #658

How Has This Been Tested?

Manual tests.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have added tests to cover my changes
  • I have made corresponding changes to the documentation

@imalexoff imalexoff force-pushed the feature/librdkafka-log-handler branch from 2a2b5fa to 02f3865 Compare September 26, 2025 13:22
@brmagadutra brmagadutra force-pushed the feature/librdkafka-log-handler branch from 02f3865 to e08cc91 Compare December 4, 2025 14:16
logHandler.Verbose(message, data);
break;
default:
throw new ArgumentOutOfRangeException(nameof(logMessage.Level), logMessage.Level, null);
Copy link

@BLage BLage Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think it is worth throwing an exception because of log messages.
IMO if log level is not known it should fallback to DEBUG, while there is no evolution on this switch to support it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you, but then it seems to me that if a level arrives that your code doesn't recognize, that's unusual by itself. Logging it as Debug or Verbose hides it among "noise". Therefore, I would use a Warning is more likely to show up in monitoring, alerts, and dashboards. You will notice faster that the system received an unexpected level.

@imalexoff imalexoff force-pushed the feature/librdkafka-log-handler branch from e08cc91 to 0af5592 Compare December 4, 2025 18:44
@imalexoff imalexoff requested a review from BLage December 4, 2025 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Intercept librdkafka logs

2 participants