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

Logging level middleware #2268

Closed
wants to merge 2 commits into from
Closed

Logging level middleware #2268

wants to merge 2 commits into from

Conversation

beykansen
Copy link

I added level field to logging template and allow customize with LevelSetter function for different use cases. For example, you can set level to info by just checking err == nil and/or you can set error when request responded with 500
and/or error is not nil.

Adding level field to logs allows better filtering and observability in your log stack.

@aldas
Copy link
Contributor

aldas commented Sep 9, 2022

Maybe using https://echo.labstack.com/middleware/logger/#customizable-function-based-requestlogger would make more sense? and you could start using proper logging library like https://github.com/rs/zerolog , https://github.com/uber-go/zap etc

@aldas
Copy link
Contributor

aldas commented Dec 1, 2022

I think this feature is covered now with #2341 This PR allows you to have custom tag with callback that can access context. so you can add anything you want to logger row - single or multiple tags etc.

e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
		Format: `{"method":"${method}",${custom}}` + "\n",
		CustomTagFunc: func(c echo.Context, buf *bytes.Buffer) (int, error) {
			return buf.WriteString(`"tag":"my-value"`)
		},
}))

@lammel
Copy link
Contributor

lammel commented Dec 2, 2022

As discussed we will close this in favor of #2341 which is already merged.

Thanks though for this PR @beykansen and your thoughts

@lammel lammel closed this Dec 2, 2022
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

3 participants