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

Customize Faraday logger formatter #44

Merged
merged 1 commit into from
Jun 25, 2020
Merged

Customize Faraday logger formatter #44

merged 1 commit into from
Jun 25, 2020

Conversation

BanzaiMan
Copy link
Contributor

In particular, add the ability to log X-* response headers. GitHub
provides useful information such as x-github-request-id. With this
option, we get the following logs:

[1] pry(main)> require 'gh'
=> true
[2] pry(main)> GH.set :formatter => 'response_x_header_formatter'
=> {:formatter=>"response_x_header_formatter"}
[3] pry(main)> GH.head '/'
I, [2020-06-24T17:27:02.309042 #15465]  INFO -- Response: {"x-content-type-options"=>"nosniff", "x-frame-options"=>"deny", "x-github-media-type"=>"github.v3; format=json", "x-github-request-id"=>"F786:7114:AF4F41:12EC65F:5EF3C526", "x-ratelimit-limit"=>"60", "x-ratelimit-remaining"=>"58", "x-ratelimit-reset"=>"1593037573", "x-xss-protection"=>"1; mode=block"}
=> {"_links"=>{"self"=>{"href"=>"https://api.github.com/"}}}

In particular, add the ability to log `X-*` response headers. GitHub
provides useful information such as `x-github-request-id`. With this
option, we get the following logs:

    [1] pry(main)> require 'gh'
    => true
    [2] pry(main)> GH.set :formatter => 'response_x_header_formatter'
    => {:formatter=>"response_x_header_formatter"}
    [3] pry(main)> GH.head '/'
    I, [2020-06-24T17:27:02.309042 #15465]  INFO -- Response: {"x-content-type-options"=>"nosniff", "x-frame-options"=>"deny", "x-github-media-type"=>"github.v3; format=json", "x-github-request-id"=>"F786:7114:AF4F41:12EC65F:5EF3C526", "x-ratelimit-limit"=>"60", "x-ratelimit-remaining"=>"58", "x-ratelimit-reset"=>"1593037573", "x-xss-protection"=>"1; mode=block"}
    => {"_links"=>{"self"=>{"href"=>"https://api.github.com/"}}}
@BanzaiMan BanzaiMan merged commit 133df7a into master Jun 25, 2020
@BanzaiMan BanzaiMan deleted the ha-extra-logging branch June 25, 2020 14:38
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.

1 participant