Skip to content

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.

3 participants