@@ -177,10 +177,10 @@ func (handler *UnroutedHandler) Middleware(h http.Handler) http.Handler {
177
177
// We also update the write deadline, but makes sure that it is larger than the read deadline, so we
178
178
// can still write a response in the case of a read timeout.
179
179
if err := c .resC .SetReadDeadline (time .Now ().Add (handler .config .NetworkTimeout )); err != nil {
180
- c .log .Warn ( "NetworkControlError" , "error" , err )
180
+ c .log .WarnContext ( c , "NetworkControlError" , "error" , err )
181
181
}
182
182
if err := c .resC .SetWriteDeadline (time .Now ().Add (2 * handler .config .NetworkTimeout )); err != nil {
183
- c .log .Warn ( "NetworkControlError" , "error" , err )
183
+ c .log .WarnContext ( c , "NetworkControlError" , "error" , err )
184
184
}
185
185
186
186
// Allow overriding the HTTP method. The reason for this is
@@ -190,7 +190,7 @@ func (handler *UnroutedHandler) Middleware(h http.Handler) http.Handler {
190
190
r .Method = newMethod
191
191
}
192
192
193
- c .log .Info ( "RequestIncoming" )
193
+ c .log .InfoContext ( c , "RequestIncoming" )
194
194
195
195
handler .Metrics .incRequestsTotal (r .Method )
196
196
@@ -405,7 +405,7 @@ func (handler *UnroutedHandler) PostFile(w http.ResponseWriter, r *http.Request)
405
405
406
406
handler .Metrics .incUploadsCreated ()
407
407
c .log = c .log .With ("id" , id )
408
- c .log .Info ( "UploadCreated" , "size" , size , "url" , url )
408
+ c .log .InfoContext ( c , "UploadCreated" , "size" , size , "url" , url )
409
409
410
410
if handler .config .NotifyCreatedUploads {
411
411
handler .CreatedUploads <- newHookEvent (c , info )
@@ -572,7 +572,7 @@ func (handler *UnroutedHandler) PostFileV2(w http.ResponseWriter, r *http.Reques
572
572
573
573
handler .Metrics .incUploadsCreated ()
574
574
c .log = c .log .With ("id" , id )
575
- c .log .Info ( "UploadCreated" , "size" , info .Size , "url" , url )
575
+ c .log .InfoContext ( c , "UploadCreated" , "size" , info .Size , "url" , url )
576
576
577
577
if handler .config .NotifyCreatedUploads {
578
578
handler .CreatedUploads <- newHookEvent (c , info )
@@ -891,7 +891,7 @@ func (handler *UnroutedHandler) writeChunk(c *httpContext, resp HTTPResponse, up
891
891
maxSize = length
892
892
}
893
893
894
- c .log .Info ( "ChunkWriteStart" , "maxSize" , maxSize , "offset" , offset )
894
+ c .log .InfoContext ( c , "ChunkWriteStart" , "maxSize" , maxSize , "offset" , offset )
895
895
896
896
var bytesWritten int64
897
897
var err error
@@ -907,12 +907,12 @@ func (handler *UnroutedHandler) writeChunk(c *httpContext, resp HTTPResponse, up
907
907
// Update the read deadline for every successful read operation. This ensures that the request handler
908
908
// keeps going while data is transmitted but that dead connections can also time out and be cleaned up.
909
909
if err := c .resC .SetReadDeadline (time .Now ().Add (handler .config .NetworkTimeout )); err != nil {
910
- c .log .Warn ( "NetworkTimeoutError" , "error" , err )
910
+ c .log .WarnContext ( c , "NetworkTimeoutError" , "error" , err )
911
911
}
912
912
913
913
// The write deadline is updated accordingly to ensure that we can also write responses.
914
914
if err := c .resC .SetWriteDeadline (time .Now ().Add (2 * handler .config .NetworkTimeout )); err != nil {
915
- c .log .Warn ( "NetworkTimeoutError" , "error" , err )
915
+ c .log .WarnContext ( c , "NetworkTimeoutError" , "error" , err )
916
916
}
917
917
}
918
918
@@ -935,7 +935,7 @@ func (handler *UnroutedHandler) writeChunk(c *httpContext, resp HTTPResponse, up
935
935
// it in the response, if the store did not also return an error.
936
936
bodyErr := c .body .hasError ()
937
937
if bodyErr != nil {
938
- c .log .Error ( "BodyReadError" , "error" , bodyErr .Error ())
938
+ c .log .ErrorContext ( c , "BodyReadError" , "error" , bodyErr .Error ())
939
939
if err == nil {
940
940
err = bodyErr
941
941
}
@@ -947,12 +947,12 @@ func (handler *UnroutedHandler) writeChunk(c *httpContext, resp HTTPResponse, up
947
947
if terminateErr := handler .terminateUpload (c , upload , info ); terminateErr != nil {
948
948
// We only log this error and not show it to the user since this
949
949
// termination error is not relevant to the uploading client
950
- c .log .Error ( "UploadStopTerminateError" , "error" , terminateErr .Error ())
950
+ c .log .ErrorContext ( c , "UploadStopTerminateError" , "error" , terminateErr .Error ())
951
951
}
952
952
}
953
953
}
954
954
955
- c .log .Info ( "ChunkWriteComplete" , "bytesWritten" , bytesWritten )
955
+ c .log .InfoContext ( c , "ChunkWriteComplete" , "bytesWritten" , bytesWritten )
956
956
957
957
// Send new offset to client
958
958
newOffset := offset + bytesWritten
@@ -1003,7 +1003,7 @@ func (handler *UnroutedHandler) emitFinishEvents(c *httpContext, resp HTTPRespon
1003
1003
resp = resp .MergeWith (resp2 )
1004
1004
}
1005
1005
1006
- c .log .Info ( "UploadFinished" , "size" , info .Size )
1006
+ c .log .InfoContext ( c , "UploadFinished" , "size" , info .Size )
1007
1007
handler .Metrics .incUploadsFinished ()
1008
1008
1009
1009
if handler .config .NotifyCompleteUploads {
@@ -1239,7 +1239,7 @@ func (handler *UnroutedHandler) terminateUpload(c *httpContext, upload Upload, i
1239
1239
handler .TerminatedUploads <- newHookEvent (c , info )
1240
1240
}
1241
1241
1242
- c .log .Info ( "UploadTerminated" )
1242
+ c .log .InfoContext ( c , "UploadTerminated" )
1243
1243
handler .Metrics .incUploadsTerminated ()
1244
1244
1245
1245
return nil
@@ -1253,7 +1253,7 @@ func (handler *UnroutedHandler) sendError(c *httpContext, err error) {
1253
1253
var detailedErr Error
1254
1254
1255
1255
if ! errors .As (err , & detailedErr ) {
1256
- c .log .Error ( "InternalServerError" , "message" , err .Error ())
1256
+ c .log .ErrorContext ( c , "InternalServerError" , "message" , err .Error ())
1257
1257
detailedErr = NewError ("ERR_INTERNAL_SERVER_ERROR" , err .Error (), http .StatusInternalServerError )
1258
1258
}
1259
1259
@@ -1271,7 +1271,7 @@ func (handler *UnroutedHandler) sendError(c *httpContext, err error) {
1271
1271
func (handler * UnroutedHandler ) sendResp (c * httpContext , resp HTTPResponse ) {
1272
1272
resp .writeTo (c .res )
1273
1273
1274
- c .log .Info ( "ResponseOutgoing" , "status" , resp .StatusCode , "body" , resp .Body )
1274
+ c .log .InfoContext ( c , "ResponseOutgoing" , "status" , resp .StatusCode , "body" , resp .Body )
1275
1275
}
1276
1276
1277
1277
// Make an absolute URLs to the given upload id. If the base path is absolute
@@ -1432,7 +1432,7 @@ func (handler *UnroutedHandler) lockUpload(c *httpContext, id string) (Lock, err
1432
1432
1433
1433
// No need to wrap this in a sync.OnceFunc because c.cancel will be a noop after the first call.
1434
1434
releaseLock := func () {
1435
- c .log .Info ( "UploadInterrupted" )
1435
+ c .log .InfoContext ( c , "UploadInterrupted" )
1436
1436
c .cancel (ErrUploadInterrupted )
1437
1437
}
1438
1438
0 commit comments