[feat] Add pulsar_logger_t as the configurable C logger#162
Merged
BewareMyPower merged 1 commit intoapache:mainfrom Jan 4, 2023
Merged
[feat] Add pulsar_logger_t as the configurable C logger#162BewareMyPower merged 1 commit intoapache:mainfrom
BewareMyPower merged 1 commit intoapache:mainfrom
Conversation
### Motivation The current `pulsar_client_configuration_set_logger` API can only configure the `Logger::log` method, but the` Logger::isEnabled` method cannot be configured via C API. apache#158 added a `pulsar_client_configuration_set_logger_and_level` function to configure a log level, but it's not flexible. For example, the log level might be modified dynamically (though it's a complicated case). ### Modifications Add a `pulsar_logger_t` struct and the related `pulsar_client_configuration_set_logger_t` function to configure it as the C logger API. The `is_enabled` and `log` fields of the struct are the responding methods of the `isEnabled` and `log` methods in C++ `Logger`. Then add a `LogContext` example in `SampleCustomLoggerCApi.c` to print logs to a file or standard output. Eliminate the `pulsar_client_configuration_set_logger_and_level` function.
Contributor
Author
|
@shibd @RobertIndie I added a more flexible interface to configure the C logger, so I removed the function added in the previous PR (#158). The PR also documents and shows to use the |
shibd
approved these changes
Dec 30, 2022
Demogorgon314
approved these changes
Jan 4, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The current
pulsar_client_configuration_set_loggerAPI can only configure theLogger::logmethod, but theLogger::isEnabledmethod cannot be configured via C API.#158 added a
pulsar_client_configuration_set_logger_and_levelfunction to configure a log level, but it's not flexible. For example, the log level might be modified dynamically (though it's a complicated case).Modifications
Add a
pulsar_logger_tstruct and the relatedpulsar_client_configuration_set_logger_tfunction to configure it as the C logger API. Theis_enabledandlogfields of the struct are the responding methods of theisEnabledandlogmethods in C++Logger.Then add a
LogContextexample inSampleCustomLoggerCApi.cto print logs to a file or standard output.Eliminate the
pulsar_client_configuration_set_logger_and_levelfunction.Documentation
doc-required(Your PR needs to update docs and you will update later)
doc-not-needed(Please explain why)
doc(Your PR contains doc changes)
doc-complete(Docs have been already added)