Skip to content
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

git library is noisy #245

Open
driusan opened this issue Apr 5, 2019 · 2 comments
Open

git library is noisy #245

driusan opened this issue Apr 5, 2019 · 2 comments

Comments

@driusan
Copy link
Owner

driusan commented Apr 5, 2019

The git subpackage uses Go's log package to print debugging information, which is suppressed by package main unless DGIT_TRACE is set.

I think this logic is backwards, because anyone who imports "github.com/driusan/dgit/git" to work with a git repo gets the noisy output by default and needs to manually suppress it. It also means that anyone using package log for their own purposes can't use the library.

We should probably be setting a logger in an init function in package git which discards by default, and adding a SetDebug(log.Logger) method (or perhaps something on the client object) to make the git subpackage more useful outside of the dgit command line without jumping through extra hoops.

@guidopola
Copy link
Contributor

Hi @driusan I would love to work on this!

@driusan
Copy link
Owner Author

driusan commented Apr 6, 2019

Feel free.. I think the best way to do it is to add a logger to the Client struct which initializes from NewClient similarly to how func main() does when DGIT_TRACE isn't set so that it discards the output, then update all the log.X calls to c.log.X, and then invert the logic in main so that it sets the client's logger to stderr if DGIT_TRACE is set, instead of suppressing it if it's not, that way anyone else using the package is free to use the log package however they want without conflicting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants