Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #87 +/- ##
==========================
==========================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a new configuration hook to let callers override the log message produced by the Echo slog logging middleware.
Changes:
- Add
WithCustomMessagecallback toConfig. - Invoke
WithCustomMessage(when provided) to override the final log message. - Document the new
Configfield in the README config snippet.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| middleware.go | Adds WithCustomMessage to the middleware config and uses it to override the logged message. |
| README.md | Updates the documented Config struct to include WithCustomMessage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| WithTraceID bool | ||
| WithClientIP bool | ||
| WithCustomMessage func(c echo.Context, err error) string | ||
|
|
||
| Filters []Filter |
There was a problem hiding this comment.
Adding an exported field to Config is a source-breaking change for consumers who use unkeyed struct literals (slogecho.Config{...}) because the field order changes. This may conflict with the README promise of no breaking changes before v2; consider an alternative extension mechanism (e.g., functional options) or explicitly bump the major version / document that only keyed literals are supported.
| } | ||
|
|
||
| if config.WithCustomMessage != nil { | ||
| msg = config.WithCustomMessage(c, errMsg) |
There was a problem hiding this comment.
WithCustomMessage is passed errMsg, which is sometimes replaced with errors.New(httpErr.Message) for *echo.HTTPError (string message). That means the callback can’t inspect the original *echo.HTTPError (code/message/internal) or any wrapped/internal error; if the intent is to let users customize based on the real error, pass err (or httpErr) instead, or rename/adjust the callback contract to make it clear it receives a sanitized error.
| msg = config.WithCustomMessage(c, errMsg) | |
| msg = config.WithCustomMessage(c, err) |
No description provided.