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

Add support for setting a logger #570

Merged
merged 2 commits into from
Aug 11, 2017
Merged

Conversation

brandur
Copy link
Contributor

@brandur brandur commented Aug 11, 2017

Adds support for setting Stripe.logger to a logger that's compatible
with Logger from Ruby's standard library. In set, the library will no
longer log to stdout, and instead emit straight to the logger and defer
decision on what log level to print to it.

Addresses a request in #566.

@brandur
Copy link
Contributor Author

brandur commented Aug 11, 2017

I suppose I should support error output as well ...

Adds support for setting `Stripe.logger` to a logger that's compatible
with `Logger` from Ruby's standard library. In set, the library will no
longer log to stdout, and instead emit straight to the logger and defer
decision on what log level to print to it.

Addresses a request in #566.
A few changes:

* Add a new `Util.log_error` method which will forward to the equivalent
  of `#error` on a logger.
* Move errors produced by `StripeClient` to use `Util.log_error`.
* Change standard stdout logging behavior to log to stderr in the case
  of `Util.log_error.
* Change `Stripe.log_level` values to be an enum in a similar fashion as
  the standard library's built in `Logger`.
@brandur
Copy link
Contributor Author

brandur commented Aug 11, 2017

Alright, I added support for printing errors to the logger's #error and tweaked the library to send them to stderr instead of stdout, which is what we should've been doing since the beginning anyway.

@brandur
Copy link
Contributor Author

brandur commented Aug 11, 2017

r? @deontologician-stripe Mind taking a look at this?

@deontologician-stripe
Copy link

LGTM

@brandur
Copy link
Contributor Author

brandur commented Aug 11, 2017

Thanks Josh!

@brandur-stripe brandur-stripe merged commit 92d28b3 into master Aug 11, 2017
@brandur-stripe brandur-stripe deleted the brandur-support-logger branch August 11, 2017 21:59
@brandur-stripe
Copy link
Contributor

Released as 3.3.0.

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

Successfully merging this pull request may close these issues.

3 participants