-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Support for python native logging from python wrapper #5279
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
Conversation
merlimat
left a comment
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.
The change LGTM, just one comment on making more efficient the checking for log level.
| Py_XDECREF(_pyLogger); | ||
| } | ||
|
|
||
| bool isEnabled(Level level) { |
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.
It might be overkill to get back into Python each time to check the log level. This will be called many times (eg. for the debug statements). is the logging level supposed to be changed frequently at runtime? Could we cache it in c++ land and only check on python every 1sec or so?
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.
For example, we have a RateLimiter in the perf directory. We could try to reuse the same class to "limit" the number of times/s we're checking what's the current log level
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.
Thank you for the suggestion! It seems to me that RateLimiter blocks the caller and I think that it's not the intended behavior. Please correct me if I am wrong.
Taking into account that in real life you would not want to change the level at run-time very often, I propose the following options:
Solution 1:
- Initialize a class member
currentLoggingLevelduring the construction of the Logger, by calling the python's "logger.getEffectiveLevel()". Then never update this value. This would imply that whenever the python programmer wants to change the logging behavior he would have to recycle the Client object.
Solution 2:
- Add an internal counter to the logger and only forward the call to python each Nth time
Logger::isEnabledis called.
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.
Thank you for the suggestion! It seems to me that RateLimiter blocks the caller and I think that it's not the intended behavior. Please correct me if I am wrong.
Oh, that's right. I confused with the Java RateLimiter class which also has tryAcquire() which is non-blocking.
Solution 1:
I think that should be fine to start with
Solution 2:
It might be tricky to understand "when" the change is taken into account
Another possibility could be to just update a timestamp of the last time the effective level was refreshed. If it was more than 1sec, then refresh it and update the timer. There should be no need of synchronization, since it doesn't have to be perfectly correct.
merlimat
left a comment
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.
👍
|
run integration tests |
1 similar comment
|
run integration tests |
|
May I please have some help or hints with the Integration Tests? To say the least, I am not familiar enough with the project to know how to start fixing this issue. Thank you! |
|
run integration tests |
|
run integration tests |
|
@BlackJohnny, above comments "run integration tests" is a trigger for the jenkins integration tests, github will handle it. |
|
run integration tests |
1 similar comment
|
run integration tests |
|
run integration tests |
1 similar comment
|
run integration tests |
|
run integration tests |
7 similar comments
|
run integration tests |
|
run integration tests |
|
run integration tests |
|
run integration tests |
|
run integration tests |
|
run integration tests |
|
run integration tests |
|
@BlackJohnny do you mind rebasing this pull request to latest master to include some of the test fixes? I can't do it since you are creating a pull request based on the master of your fork. |
Done. Is it moved to 2.6 because of my late reaction? |
|
@BlackJohnny the community is currently deploying a time based release schedule. so I move the issue to 2.6.0 since I wasn't sure when this pull request will be taken care of as this pull request was made of your master branch and I can't change it. |
|
retest this please |
1 similar comment
|
retest this please |
|
@BlackJohnny Can you please rebase this pull request to latest master? Also it would be good to send the pull request from a non-master branch. The committers can help you rebase branch to latest master as needed. |
|
Recreated pull-request from non-master branch |
Fixes #5620
Added support for Python native logging within the Pulsar Client Python wrapper.
pulsar.Clientvia theClientConfigurationobjectTested with tag/2.4.1