question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: disable "live logging" by default and write to terminal writer instead

See original GitHub issue

The Live Logs feature currently is enabled by default and requires the user to pass -s to see the logs.

I see two problems:

  1. 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.
  2. 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:

  1. Create a new property, live_logs, defaulting to False.
  2. 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:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:43 (26 by maintainers)

github_iconTop GitHub Comments

1reaction
nicoddemuscommented, Jan 16, 2018

Finally got time to work on this proposal, #3124 is open and all comments are welcome.

1reaction
ederagcommented, Jan 3, 2018

@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 to stderr. For this app, it is currently the main feedback mechanism to the user. In this case, --no-print-logs is preferable.

logging is not configured by Python by default, perhaps pytest should follow the same logic

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 ?)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found