-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
implement python logger wrapper #7713
Conversation
5f17396
to
deebbe8
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.
Looks good. Mey be add at least some simple test, if it is managable?
0c09e10
to
6fcf18f
Compare
@pinkavaj could you take another look please? |
9a16be7
to
11be0b3
Compare
return _getLogLevelValue(level) >= _currentPythonLogLevel; | ||
} | ||
|
||
void log(Level level, int line, const std::string& message) { |
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 file and line information is not logged, but I'm not familiar with the code enought to decide what is more appropriate. From the point of developer I would preffer the file and line information in the log message.
Probably someone more familiar with this code should speek his opinion.
Otherwise looks good.
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.
Feel free to show example and you incentive to help with decission.
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.
Not having this info only truly matters if the Python Logger
is connected ultimately to one or more Formatter
s that has tokens like filename
, pathname
or lineno
in its format string.
It should be possible to create a LogRecord
object (https://docs.python.org/3/library/logging.html#logrecord-objects) and pass it to Logger.handle
method instead of using the simpler info
, warning
etc methods. I for one think it is not worth the trouble and the implementation is fine as-is.
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 @Bklyn, please consider approving the PR
11be0b3
to
54ebbdb
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.
Looks good to be with the small exception of not initializing the _logger
string member in the copy-ctor and assignment operator, but is this member even used for anything? I might suggest dropping it entirely.
f49f281
to
7048f59
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.
Looks good to me!
rebase this on master. |
7048f59
to
e82dab9
Compare
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
Does anyone know the why the unit test run was cancelled? |
Hi everyone, thank you for the effort put in this pull request! Would be possible to release a version compatible with python2.7 that includes these changes? Thank you! |
Fixes apache#4234 ### Motivation Logging in the python client is not configurable, so the stdout was spammed. This PR revives the apache#6113 but tries to resolve the bugs that resulted the last time. ### Modifications Implemented a python logger wrapper. You can pass a python logger as an argument to the client. ### Verifying this change - [ ] Make sure that the change passes the CI checks. Not sure how to unit-test this. I tested it manually by building the client and trying it out with python scripts. It works as expected both with the logger forwarded and without. Also, configuring the logger also configures the log level so this fixes the problem.
Now this is merged I can't seem to get it working. I suspect it is because this logger is not loaded in the C++.
I see the normal python logger suppresses the info messages but the prefect-client 2.8 still prints all |
Fixes apache#4234 ### Motivation Logging in the python client is not configurable, so the stdout was spammed. This PR revives the apache#6113 but tries to resolve the bugs that resulted the last time. ### Modifications Implemented a python logger wrapper. You can pass a python logger as an argument to the client. ### Verifying this change - [ ] Make sure that the change passes the CI checks. Not sure how to unit-test this. I tested it manually by building the client and trying it out with python scripts. It works as expected both with the logger forwarded and without. Also, configuring the logger also configures the log level so this fixes the problem.
Fixes #4234
Motivation
Logging in the python client is not configurable, so the stdout was spammed. This PR revives the #6113 but tries to resolve the bugs that resulted the last time.
Modifications
Implemented a python logger wrapper. You can pass a python logger as an argument to the client.
Verifying this change
Not sure how to unit-test this. I tested it manually by building the client and trying it out with python scripts. It works as expected both with the logger forwarded and without. Also, configuring the logger also configures the log level so this fixes the problem.
Does this pull request potentially affect one of the following parts:
If
yes
was chosen, please highlight the changesDocumentation