Skip to content

feat: adding WithCustomMessage#87

Merged
samber merged 1 commit intomainfrom
feat/with-custom-message
Feb 14, 2026
Merged

feat: adding WithCustomMessage#87
samber merged 1 commit intomainfrom
feat/with-custom-message

Conversation

@samber
Copy link
Owner

@samber samber commented Feb 14, 2026

No description provided.

Copilot AI review requested due to automatic review settings February 14, 2026 00:10
@samber samber merged commit 77b4954 into main Feb 14, 2026
16 checks passed
@codecov
Copy link

codecov bot commented Feb 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (9a4d16e) to head (ab68056).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@    Coverage Diff     @@
##   main   #87   +/-   ##
==========================
==========================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 WithCustomMessage callback to Config.
  • Invoke WithCustomMessage (when provided) to override the final log message.
  • Document the new Config field 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.

Comment on lines 53 to 57
WithTraceID bool
WithClientIP bool
WithCustomMessage func(c echo.Context, err error) string

Filters []Filter
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
}

if config.WithCustomMessage != nil {
msg = config.WithCustomMessage(c, errMsg)
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
msg = config.WithCustomMessage(c, errMsg)
msg = config.WithCustomMessage(c, err)

Copilot uses AI. Check for mistakes.
@samber samber deleted the feat/with-custom-message branch February 14, 2026 00:13
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.

2 participants