Proposal: disable "live logging" by default and write to terminal writer instead
See original GitHub issueThe Live Logs feature currently is enabled by default and requires the user to pass -s
to see the logs.
I see two problems:
- If the user is interested in the feature, having to pass
-s
feels clumsy because now all sort of outputs will come through, reducing the actual usefulness of the feature because it will be harder to see the actual logging messages. - To solve 1), I believe we will need to write to the TerminalWriter, which by consequence will show up for all users from that point on even if they are not interested in the feature because the default is
WARNING
.
My proposal:
- Create a new property,
live_logs
, defaulting toFalse
. - Write the “live logs” to the TerminalWriter, probably in color according to the level, yellow for WARNING and red for CRITICAL. This means users won’t need to use
-s
to see live logs anymore.
This feature was originally implemented in eisensheng/pytest-catchlog#33 but was never released to PyPI, so I assume “live logs” has seen little use in the wild.
cc @thisch
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:43 (26 by maintainers)
Top Results From Across the Web
How do I disable messages or logging from printing on the ...
You can use the command sudo dmesg -n 1. to suppress all messages from the kernel (and its drivers) except panic messages from...
Read more >How can I disable logging while running unit tests in Python ...
Is there a simple way to turn off logging in a global way, so that the application specific loggers aren't writing stuff out...
Read more >Route logs to supported destinations - Google Cloud
This document explains how to create and manage sinks to route log entries to supported destinations. Note: If your data is managed through...
Read more >Logging in Python - Real Python
Similarly, for logging to a file rather than the console, filename and ... The default setting in basicConfig() is to set the logger...
Read more >How To Use Logging in Python 3 | DigitalOcean
While the print() statement allows us to see that the code is working, we can use the logging module to do this instead....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Finally got time to work on this proposal, #3124 is open and all comments are welcome.
@nicoddemus Yes, it is a different use case, not related to pytest. The application uses the python logger with a basic
logging.StreamHandler()
that outputs tostderr
. For this app, it is currently the main feedback mechanism to the user. In this case,--no-print-logs
is preferable.Exactly, the application logger level should not be tampered with during the tests, unless explicitly requested. (otherwise, how to check that the default logging level of the app is correct ?)