handler: Refactor logging of UploadFinished and UploadTerminated into handler
This commit is contained in:
parent
a75c24996f
commit
d5eca08944
|
@ -1,7 +1,6 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/tus/tusd/v2/cmd/tusd/cli/hooks"
|
||||
|
@ -125,14 +124,6 @@ func invokeHookSync(typ hooks.HookType, event handler.HookEvent) (httpRes handle
|
|||
MetricsHookInvocationsTotal.WithLabelValues(string(typ)).Add(1)
|
||||
|
||||
id := event.Upload.ID
|
||||
size := event.Upload.Size
|
||||
|
||||
switch typ {
|
||||
case hooks.HookPostFinish:
|
||||
logEv(stdout, "UploadFinished", "id", id, "size", strconv.FormatInt(size, 10))
|
||||
case hooks.HookPostTerminate:
|
||||
logEv(stdout, "UploadTerminated", "id", id)
|
||||
}
|
||||
|
||||
if hookHandler == nil {
|
||||
return httpRes, nil
|
||||
|
|
|
@ -678,6 +678,7 @@ func (handler *UnroutedHandler) finishUploadIfComplete(c *httpContext, resp HTTP
|
|||
resp = resp.MergeWith(resp2)
|
||||
}
|
||||
|
||||
handler.log("UploadFinished", "id", info.ID, "size", strconv.FormatInt(info.Size, 10))
|
||||
handler.Metrics.incUploadsFinished()
|
||||
|
||||
// ... send the info out to the channel
|
||||
|
@ -882,6 +883,7 @@ func (handler *UnroutedHandler) terminateUpload(c *httpContext, upload Upload, i
|
|||
handler.TerminatedUploads <- newHookEvent(info, c.req)
|
||||
}
|
||||
|
||||
handler.log("UploadTerminated", "id", info.ID)
|
||||
handler.Metrics.incUploadsTerminated()
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue