Skip to content

Commit

Permalink
Support the log/slog ErrorContext function
Browse files Browse the repository at this point in the history
  • Loading branch information
janos committed Aug 2, 2023
1 parent 448e6e9 commit bb53e43
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21.0-rc.2'
go-version: '1.21.0-rc.3'

- name: Checkout
uses: actions/checkout@v1
Expand Down
6 changes: 3 additions & 3 deletions recovery/recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if h.label != "" {
debugMsg = h.label + "\n\n" + debugMsg
}
h.logger.ErrorCtx(ctx, "http recovery handler", "method", r.Method, "url", r.URL.String(), "error", err, "debug", debugMsg)
h.logger.ErrorContext(ctx, "http recovery handler", "method", r.Method, "url", r.URL.String(), "error", err, "debug", debugMsg)

if h.notifier != nil {
go func() {
defer func() {
if err := recover(); err != nil {
h.logger.ErrorCtx(ctx, "http recovery handler: notify panic", slog.Any("error", err))
h.logger.ErrorContext(ctx, "http recovery handler: notify panic", slog.Any("error", err))
}
}()

Expand All @@ -107,7 +107,7 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
),
debugMsg,
); err != nil {
h.logger.ErrorCtx(ctx, "http recovery handler: notify", slog.Any("error", err))
h.logger.ErrorContext(ctx, "http recovery handler: notify", slog.Any("error", err))
}
}()
}
Expand Down
2 changes: 1 addition & 1 deletion servers/servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func (s *Servers) Shutdown(ctx context.Context) {

s.logger.Info("shutting down server", "name", srv.label())
if err := srv.Shutdown(ctx); err != nil {
s.logger.ErrorCtx(ctx, "shutting down server", "name", srv.label(), "error", err)
s.logger.ErrorContext(ctx, "shutting down server", "name", srv.label(), "error", err)
}
}(srv)
}
Expand Down

0 comments on commit bb53e43

Please sign in to comment.