File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -38,9 +38,10 @@ func Logger(log slog.Logger) func(next http.Handler) http.Handler {
38
38
logContext := & RequestLoggerContext {
39
39
log : & httplog ,
40
40
written : false ,
41
+ message : r .Method ,
41
42
}
42
43
defer func () {
43
- logContext .WriteLog (r .Context (), "" , sw .Status )
44
+ logContext .WriteLog (r .Context (), sw .Status )
44
45
}()
45
46
46
47
ctx := context .WithValue (r .Context (), logContextKey {}, logContext )
@@ -88,23 +89,24 @@ func Logger(log slog.Logger) func(next http.Handler) http.Handler {
88
89
type RequestLoggerContext struct {
89
90
log * slog.Logger
90
91
written bool
92
+ message string
91
93
}
92
94
93
95
func (c * RequestLoggerContext ) WithFields (fields ... slog.Field ) {
94
96
newLogger := c .log .With (fields ... )
95
97
c .log = & newLogger
96
98
}
97
99
98
- func (c * RequestLoggerContext ) WriteLog (ctx context.Context , msg string , status int ) {
100
+ func (c * RequestLoggerContext ) WriteLog (ctx context.Context , status int ) {
99
101
if c .written {
100
102
return
101
103
}
102
104
c .written = true
103
105
104
106
if status >= http .StatusInternalServerError {
105
- c .log .Error (ctx , msg )
107
+ c .log .Error (ctx , c . message , "status_code" , status )
106
108
} else {
107
- c .log .Debug (ctx , msg )
109
+ c .log .Debug (ctx , c . message , "status_code" , status )
108
110
}
109
111
}
110
112
Original file line number Diff line number Diff line change @@ -556,7 +556,7 @@ func (f *logFollower) follow() {
556
556
557
557
// write the initial logs to the connection
558
558
httpmw .FromContext (f .ctx ).WriteLog (
559
- f .ctx , "ProvisionerJobs log follower WS connection established" , http .StatusAccepted )
559
+ f .ctx , http .StatusAccepted )
560
560
561
561
// no need to wait if the job is done
562
562
if f .complete {
You can’t perform that action at this time.
0 commit comments