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

Adding default fields renaming feature #13

Merged
merged 2 commits into from May 29, 2018

Conversation

pbrudnick
Copy link
Contributor

I want to rename keys to get it working with my other web apps.

You can rename the default keys passing a list of {:key, :new_key} tuples:

plug Logster.Plugs.Logger, renames: [{:duration, :response_time}, {:params, :parameters}]

It will log the following:

[info] method=GET path=/articles/some-article format=html controller=HelloPhoenix.ArticleController action=show parameters={"id":"some-article"} status=200 response_time=0.402 state=set

@navinpeiris
Copy link
Owner

hi @pbrudnick, is there a reason we would want to pass the renames as a list of tuples instead of a map?

The reasons being:

  1. Might be (arguably) nicer at the point of definition:
plug Logster.Plugs.Logger, renames: %{duration: :response_time, params: :parameters}
  1. Will be easier to lookup and use the rename instead of having to iterate through the list

@pbrudnick
Copy link
Contributor Author

I totally agree with your suggestions.
I can change that if it works with the lib.

@navinpeiris
Copy link
Owner

That'll be awesome, thanks @pbrudnick

@navinpeiris navinpeiris merged commit c974438 into navinpeiris:master May 29, 2018
@navinpeiris
Copy link
Owner

Thanks @pbrudnick! I'm away from my computer now, will cut a new release tomorrow

@pbrudnick
Copy link
Contributor Author

Thank you @navinpeiris!

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

Successfully merging this pull request may close these issues.

None yet

2 participants