From 973b3db042b9e8b09224186287ab537c09cf3fc4 Mon Sep 17 00:00:00 2001 From: Stefan Saasen Date: Fri, 9 Feb 2024 15:46:10 +0100 Subject: [PATCH] LogEntrySetFields: Update the example to use httplog.LogEntrySetFields --- _example/main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/_example/main.go b/_example/main.go index 28607f3..a98ff17 100644 --- a/_example/main.go +++ b/_example/main.go @@ -42,7 +42,16 @@ func main() { r.Use(func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ctx := r.Context() + + // Set a single log field httplog.LogEntrySetField(ctx, "user", slog.StringValue("user1")) + + // Set multiple fields + fields := map[string]any{ + "remote": "example.com", + "action": "update", + } + httplog.LogEntrySetFields(ctx, fields) next.ServeHTTP(w, r.WithContext(ctx)) }) })