Add an option for logging
nicklaw5 opened this issue · 4 comments
Allow users to pass in their own logger.
I would be happy to contribute, but I don't see any logging used in the code at all. Can you please provide some more info on your plans and wishes?
Yeh, I've been meaning to add logging to requests and perhaps responses(?). Essentially what I had in mind was to add a Debug and Logger field to the Options struct. The Logger should be compatible with Go's log.Logger struct. For example:
type Options struct {
ClientID string
ClientSecret string
AppAccessToken string
UserAccessToken string
UserAgent string
RedirectURI string
Scopes []string
HTTPClient HTTPClient
RateLimitFunc RateLimitFunc
+ Debug bool
+ Logger log.Logger
}
Beyond that I hadn't really thought about it. I'm happy for you to propose something.
It's definitely an important addition. Just recently I had to add some logging in the function sendRequest()
to inspect the response.
I also like your solution. Even if debug logging is often the only logging within a library, by having an additional Debug bool
field, the field can be set via environment variables.
Recommended Addition
We could use go-spew to pretty-print requests and responses, so even with many fields printed to the console they stay readable.
Update
See pull request: #6
We could use go-spew to pretty-print requests and responses, so even with many fields printed to the console they stay readable.
I would prefer that we not include external dependencies in this library. One of my goals was to write this project using Go's native packages.