Skip to content

Add support for log formatters in Tesla Middleware #16

@prodis

Description

@prodis

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions