From 7b2004ad1f623b4c0b31033bb2e847aee75ff1f4 Mon Sep 17 00:00:00 2001 From: Samuel Berthe Date: Mon, 23 Oct 2023 14:11:16 +0200 Subject: [PATCH] feat: send request context into record context --- middleware.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/middleware.go b/middleware.go index 153f6a1..03f9997 100644 --- a/middleware.go +++ b/middleware.go @@ -2,7 +2,6 @@ package sloggin import ( "bytes" - "context" "io" "net/http" "strings" @@ -194,7 +193,7 @@ func NewWithConfig(logger *slog.Logger, config Config) gin.HandlerFunc { msg = c.Errors.String() } - logger.LogAttrs(context.Background(), level, msg, attributes...) + logger.LogAttrs(c.Request.Context(), level, msg, attributes...) } }