meta_logger icon indicating copy to clipboard operation
meta_logger copied to clipboard

Add support for log formatters in Tesla Middleware

Open prodis opened this issue 2 years ago • 2 comments

There is a single fixed log format for the Tesla.Middleware.MetaLogger (and in fact not well-documented).

Request

[{tag}] {HTTP method} {URL} {headers}
[{tag}] {body}

Response:

[{tag}] {HTTP status code} {headers}
[{tag}] {body}

Example:

[MyApp.Client.Http] POST https://test.xxx.com/2.4/itineraries?token=123pim567pim&param1=value1 [{"Authorization", "[FILTERED]"}, {"Customer-Ip", "89.212.216.145"}, {"Accept", "application/json"}, {"Accept-Encoding", "gzip"}, {"Content-Type", "application/json"}, {"User-Agent", "BoFH.Providers.EPS/0.83.0"}
[MyApp.Client.Http] {"some":"body","work":"my body","customer_ip":"89.212.216.145","sensitive":"[FILTERED]"}
[MyApp.Client.Http] 201 [{"content-type", "application/json"}, {"vary", "Accept-Encoding,Accept-Encoding"}, {"location", "/path/7657854242219?token=567pim123pim"}, {"content-encoding", "gzip"}, {"content-length", "1720"}, {"date", "Thu, 25 Nov 2021 09:22:57 GMT"}, {"connection", "keep-alive"}]
[MyApp.Client.Http] {"some_id":"7657854242219","links":{"test":{"method":"GET","href":"/path/7657854242219?token=567pim123pim"}}}

Supporting log formatters, the default logger formatter could be the current one and open the flexibility to have as many as we want. For example, a log formatter for Datadog JSON or a curl output for the request.

prodis avatar Nov 25 '21 11:11 prodis