-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
caplog fails on getting caplog.messages with str.format() log record #3397
Comments
Most likely related to our handler using a special non-default format for lazy logging. Need to switch to the default one, to be compatible with default handlers. |
You mean, to move to percent-formatted strings? |
@skshetry Yeah, probably would do that to avoid messing around with different loggers. Could use their version of {} too though. |
Unfortunately overriding `format` is not enough in order to use our own custom formatting in logger. `Record` uses percent formatting that is hardcoded inside, so we would also have to override it, which is just way too much effort that will inevitably break as we discover other methods that are not ready for non-% formatting. So we are just giving up and sticking to default %-formatting for lazy log messages. Fixes iterative#3397
Unfortunately overriding `format` is not enough in order to use our own custom formatting in logger. `Record` uses percent formatting that is hardcoded inside, so we would also have to override it, which is just way too much effort that will inevitably break as we discover other methods that are not ready for non-% formatting. So we are just giving up and sticking to default %-formatting for lazy log messages. Fixes #3397
Description
In dvc we can use
logger.info
asbecause of the custom formatter
but caplog uses default LogRecord.getMessage()
and fails in tests on getting
caplog.messages
Steps to reproduce
Create a file with content
Run it
Produces an error like
Info
The text was updated successfully, but these errors were encountered: