Skip to content

Commit

Permalink
LogEntrySetFields: Update the example to use httplog.LogEntrySetFields
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansaasen committed Feb 13, 2024
1 parent 4e4e664 commit 973b3db
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions _example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
})
Expand Down

0 comments on commit 973b3db

Please sign in to comment.