-
Notifications
You must be signed in to change notification settings - Fork 897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logger with Admin Client #1758
Logger with Admin Client #1758
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments
""" | ||
Create a new AdminClient using the provided configuration dictionary. | ||
|
||
The AdminClient is a standard Kafka protocol client, supporting | ||
the standard librdkafka configuration properties as specified at | ||
https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md | ||
|
||
:param dict config: Configuration properties. At a minimum ``bootstrap.servers`` **should** be set\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be named conf
? And also the trailing \n
can be removed
""" | ||
Create a new AdminClient using the provided configuration dictionary. | ||
|
||
The AdminClient is a standard Kafka protocol client, supporting | ||
the standard librdkafka configuration properties as specified at | ||
https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md | ||
|
||
:param dict config: Configuration properties. At a minimum ``bootstrap.servers`` **should** be set\n" | ||
:param Logger logger: Optional Logger instance to use as a custom log messages handler. | ||
|
||
At least 'bootstrap.servers' should be configured. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed as it's included above now
tests/test_log.py
Outdated
stringBuffer = StringIO() | ||
logger = logging.getLogger('Admin') | ||
logger.setLevel(logging.DEBUG) | ||
handler = logging.StreamHandler(stringBuffer) | ||
handler.setFormatter(logging.Formatter('%(name)s Logger | %(message)s')) | ||
logger.addHandler(handler) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is being repeated here and the above two functions. Can be moved to setup_logger
or some helper function
examples/adminapi.py
Outdated
@@ -920,3 +928,6 @@ def example_list_offsets(a, args): | |||
sys.exit(1) | |||
|
|||
opsmap[operation](a, args) | |||
|
|||
# Log messages through custom logger if provided | |||
a.poll(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newline missing
tests/test_log.py
Outdated
logMessage = stringBuffer.getvalue().strip() | ||
stringBuffer.close() | ||
|
||
assert "Admin Logger | INIT" in logMessage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newline missing
5479623
to
a2be27b
Compare
There is inbetween manipulation of the config properties in python binding as well. Due to that part, I have to check here first. |
* Updated examples/adminapi.py to include usage of the custom logger with AdminClient
53aac04
to
5abfee1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, just a few comments
CHANGELOG.md
Outdated
- Removed usage of `strcpy` to enhance security of the client (#1745) | ||
- Fixed invalid write in `OAUTHBEARER/OIDC` extensions copy (#1745) | ||
- Fixed an issue related to import error of `TopicCollection` and `TopicPartitionInfo` classes when importing through other module like mypy. | ||
- Fixed a segfault when `commit` or `store_offsets` consumer method is called incorrectly with errored Message object | ||
- Fixed `logger` not working when provided as an argument to `AdminClient` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify it was possible before:
- Fixed `logger` not working when provided as an argument to `AdminClient` | |
- Fixed `logger` not working when provided as an argument to `AdminClient` instead of a configuration property. |
# Create Admin client | ||
a = AdminClient({'bootstrap.servers': broker, | ||
'debug': 'all'}, | ||
logger=logger) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger=logger) | |
logger=logger) | |
# Alternatively, pass the logger as a key. | |
# When passing it as an argument, it overwrites the key. | |
# | |
# a = AdminClient({'bootstrap.servers': broker, | |
# 'debug': 'all', | |
# 'logger': logger}) |
@@ -4,10 +4,12 @@ | |||
|
|||
v2.4.1 is a maintenance release with the following fixes and enhancements: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version can be changed to 2.5.0 when we merge delete_records
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already done that in delete_records as that is a new feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Pranav!
logger
not working when provided as an argument toAdminClient
examples/adminapi.py
to include usage of the custom logger withAdminClient