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

Suggestion to improve logging support #888

Closed
prikha opened this issue Feb 27, 2019 · 0 comments
Closed

Suggestion to improve logging support #888

prikha opened this issue Feb 27, 2019 · 0 comments

Comments

@prikha
Copy link
Contributor

prikha commented Feb 27, 2019

Basic Info

I am concerned about the usability of request/response logging. At the moment one should override the logging middleware like that:

Faraday::Response.register_middleware logger: -> { FaradayMiddlewares::MyLogger }

And then you have to deal with the inheritance. For example you want to change the request logging - then you have to skip using super and bring code from Faraday::Response::Middleware#call to it(To avoid duplicate logging for example). As of super would call a method from Faraday::Response::Logger and then it would propagate to Faraday::Response::Middleware.

Dealing with logging requests/response in faraday is non-transparent(for me at least). I have a suggestion(backed up by some code: #889) of separating log formatter from the logging middleware.

E.g. I would be happy to provide my formatter to the connection configuration:

conn = Faraday.new(:url => 'http://sushi.com/api_key=s3cr3t') do |faraday|
  faraday.response :logger, logger,   formatter: MyFormatter
end

That could be inherited from the base formatter with something like 2 methods to override: request and response.

Steps to reproduce

To see the issue I would recommend an exercise: integrate a structured logger(like SemanticLogger) or at least convert a multiline logging to a one-line-per-request(supporting bodies logging)

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

No branches or pull requests

1 participant