Skip to content

Prints to stderr from library #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
omgjlk opened this issue Oct 19, 2011 · 4 comments
Closed

Prints to stderr from library #33

omgjlk opened this issue Oct 19, 2011 · 4 comments
Milestone

Comments

@omgjlk
Copy link

omgjlk commented Oct 19, 2011

git/objects/commit.py has a few places where it will print to stderr if unable to decode a stream from the repo. This has ill effect on client callers to the library. In my case, I'm making use of GitPython in a git update hook, and this stderr print is making its way back to the user's console and confusing them when they push.

Can we make these prints optional?

@Byron
Copy link
Member

Byron commented Oct 19, 2011

Thanks for bringing this up. The code you mentioned is rather old and serves more for debugging purposes, as to indicate that something wrong happened at least.

I would prefer to keep some sort of message, but it should be configurable by the user of the library. Would you think that using python logging instead would be a viable option ?

If so, the few occurrences of printing directly to stderr could easily be fixed.

@omgjlk
Copy link
Author

omgjlk commented Oct 19, 2011

Sure, python logging would be appropriate. If the calling code wishes to get debug info they can hook into the logger. By default the GitPython library can use a null handler, but still make appropriate log.info and log.error calls. Any self testing code could hook into the logger and provide appropriate logging targets.

FWIW, that's exactly how I handle it in some of my libraries. The library null logs, client code adds handlers to pick up on library logging output. Client can decide quiet, info, verbosity.

@Byron Byron added this to the v0.3.4 - python 3 support milestone Nov 19, 2014
@Byron
Copy link
Member

Byron commented Nov 19, 2014

Python logging will be used consistently in 0.3.4 when making it ready for py3.

@Byron
Copy link
Member

Byron commented Jan 4, 2015

Python logging is used in 0.3.3 already, which is now online on pypi too.

@Byron Byron closed this as completed Jan 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants