[BUG] Should RichHandler default to stderr
See original GitHub issueDescribe 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:
- Created 2 years ago
- Reactions:1
- Comments:7
Top 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 >
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
I also think that the RichHandler should not change default logger behaviour, ie. it should log to stderr by default.
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.
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.