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

Add support for log formatters in Tesla Middleware #16

Open
prodis opened this issue Nov 25, 2021 · 2 comments
Open

Add support for log formatters in Tesla Middleware #16

prodis opened this issue Nov 25, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@prodis
Copy link
Collaborator

prodis commented Nov 25, 2021

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 prodis added the enhancement New feature or request label Nov 25, 2021
@prodis
Copy link
Collaborator Author

prodis commented Nov 25, 2021

And maybe could be a good idea to move the Tesla.Middleware.MetaLogger to a separate library. 💡

@nvieirafelipe
Copy link
Collaborator

And maybe could be a good idea to move the Tesla.Middleware.MetaLogger to a separate library. 💡

I think the code is too small and simple to be extracted now, not worth the effort of a major release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants