local-ch / lhc

🚀 Advanced HTTP Client for Ruby. Fueled with interceptors.
GNU General Public License v3.0
43 stars 1 forks source link

Improve json format #143

Closed sihu closed 4 years ago

sihu commented 5 years ago

MINOR

This PR improves the log-ouput for json-data:

Before:

Before LHC request<70204499078600> GET http://server.ch/******* at 2018-11-14T17:45:19+01:00 Params={} Headers={"User-Agent"=>"LHC (10.0.2; *******) [https://github.com/local-ch/lhc]", "Authorization"=>"Bearer *******", "Expect"=>""}

After:

Before LHC request<70117149524060> GET http://server.ch/******* at 2018-11-14T17:45:19+01:00 Params={} Headers={"User-Agent":"LHC (10.0.2; *******) [https://github.com/local-ch/lhc]","Authorization":"Bearer *******","Expect":""}

Reason:

Especially for errors as a developer you might want to copy the failing request and debug it in Postman or similar tools. With the JSON-Syntax this is much easier.

sihu commented 5 years ago

@spape I tried to convert all the Hash-Params of an error to json. Right now i couldn't manage to print out the request.options, since it causes a stack-level-too-deep-error. But i think my suggested change already improves the situation.

10xSebastian commented 5 years ago

Couldn't we just add JSON (as_json and/or to_json) marshaling to Interceptors? https://github.com/local-ch/lhc/blob/master/lib/lhc/interceptor.rb