Log debug and informational messages to stderr only
See original GitHub issueWhat’s the problem this feature will solve?
Commands that generate output for the user (pip list
, pip freeze
) must be concerned with debug output.
Describe the solution you’d like
As mentioned in #6099:
- all log messages should go to stderr instead of stdout
- command API related output should use a dedicated interface that outputs to stdout
Any issue that seeks to make the CLI more usable would benefit from this change. This also avoids issues like #6024.
Alternative Solutions
Originally, ad-hoc redirection of logger output to stderr was used to preserve command output. This could be used again, but it would make logging output from commands inconsistent in pip.
Additional Context
Issue Analytics
- State:
- Created 4 years ago
- Comments:22 (22 by maintainers)
Top Results From Across the Web
Python logging: debug messages logged to stderr even ...
While modifying code on an existing project, I found that debug messages were being output to stderr even though the handler ...
Read more >Do progress reports/logging information belong on stderr or ...
I was recently told that this is not good practice since progress reports aren't actually errors and only error messages should be printed...
Read more >How we use logging - Tit Petric
Split the log destination based on message severity (debug output, info, errors). For people somewhat familiar with linux, you might asume that ...
Read more >Logging - Gradle User Manual
Before Gradle 4.0 those rich components were only displayed at log level ... The DEBUG log level can expose security sensitive information to...
Read more >How To Use Google Logging Library (glog)
logtostderr ( bool , default= false ): Log messages to stderr instead of ... Special "debug mode" logging macros only have an effect...
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 FreeTop 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
Top GitHub Comments
I was planning to do this between the 19.2 and 19.3 release but would be okay with someone else doing it. (I had already done it for subprocess logging in PR #6339.)
I was thinking this should be implemented in three PR’s as follows:
Switch all command API output to use a function called something like
write_output()
whose initial implementation just delegates tologging.INFO
(so this would be a refactoring PR with no behavior change). This PR will let us review where all the API output is happening.Change the implementation of
write_output()
from using alogging
call to writing directly tostdout
.Change the logging configuration to use
stderr
streams for everything instead ofstdout
for some. This step will involve simplifying our logging config and in particular merging the subprocess logger introduced in PR #6339 with the main logger, as they would now both be using the samestderr
stream.print is probably fine, too. We can always change it if we need to. Also, you don’t necessarily want to copy the subprocess logger. It’s just an example of a different logger being used.