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.

Log debug and informational messages to stderr only

See original GitHub issue

What’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:

  1. all log messages should go to stderr instead of stdout
  2. 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:open
  • Created 4 years ago
  • Comments:22 (22 by maintainers)

github_iconTop GitHub Comments

2reactions
cjerdonekcommented, Jul 24, 2019

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:

  1. Switch all command API output to use a function called something like write_output() whose initial implementation just delegates to logging.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.

  2. Change the implementation of write_output() from using a logging call to writing directly to stdout.

  3. Change the logging configuration to use stderr streams for everything instead of stdout 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 same stderr stream.

1reaction
cjerdonekcommented, Aug 27, 2019

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.

Read more comments on GitHub >

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

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