We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 942437f commit 48fc384Copy full SHA for 48fc384
coderd/httpmw/loggermw/logger.go
@@ -4,6 +4,7 @@ import (
4
"context"
5
"fmt"
6
"net/http"
7
+ "sync"
8
"time"
9
10
"cdr.dev/slog"
@@ -71,6 +72,7 @@ type SlogRequestLogger struct {
71
72
written bool
73
message string
74
start time.Time
75
+ mu sync.RWMutex
76
actors map[rbac.SubjectType]rbac.Subject
77
}
78
@@ -91,10 +93,15 @@ func (c *SlogRequestLogger) WithFields(fields ...slog.Field) {
91
93
92
94
95
func (c *SlogRequestLogger) WithAuthContext(actor rbac.Subject) {
96
+ c.mu.Lock()
97
+ defer c.mu.Unlock()
98
c.actors[actor.Type] = actor
99
100
101
func (c *SlogRequestLogger) addAuthContextFields() {
102
+ c.mu.RLock()
103
+ defer c.mu.RUnlock()
104
+
105
usr, ok := c.actors[rbac.SubjectTypeUser]
106
if ok {
107
c.log = c.log.With(
0 commit comments