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.

[BUG] Should RichHandler default to stderr

See original GitHub issue

Describe the bug

“Bug” is a little strong, but I noticed that by default Python logging writes to stderr, but when using RichHandler by default it writes to stdout.

I know you can get around this with something like:

logging.basicConfig(
    level="DEBUG", datefmt="[%X]", handlers=[RichHandler(console=Console(stderr=True))]
)

But would it be more sensible and less surprising for new users if by default RichHandler logged to stderr?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

1reaction
robinbowescommented, Nov 18, 2022

I also think that the RichHandler should not change default logger behaviour, ie. it should log to stderr by default.

It would be surprising for some users if they piped the output and it didn’t appear

Anyone using RichHandler is already using python logging, and therefore expecting log output to go to stderr. It is more surprising for logging to not go to stderr.

This is a bug, IMO.

0reactions
imdoroshenkocommented, Aug 23, 2022

This bug caused issues in my CLI app because logs were mixed with the app output and caused errors when piping. I feel that by default rich should avoid unexpected behaviour.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why Python logging writes to stderr by default? - Stack Overflow
The reason for that is stderr is meant to be an output for all messages that are just some internal and/or debugging program...
Read more >
Logging Handler — Rich 12.6.0 documentation
Rich supplies a logging handler which will format and colorize text written by Python's logging module. Here's an example of how to set...
Read more >
https://raw.githubusercontent.com/willmcgugan/rich...
\_lru_cache ### Changed - Default width of Jupyter console size is ... docs for RichHandler which erroneously said default console writes to stderr...
Read more >
How to Enhance Nmap with Python - freeCodeCamp
Write a small script that can scan all the hosts on the local ... 2600]$ sudo -l Matching Defaults entries for josevnz on...
Read more >
python39-rich-12.5.1-1.1.noarch RPM
StringIO file (for example) then the width will be set to the current terminal dimensions and not a default of 80. Added *...
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