From 4df66415d6fd9def411319d745c85421c005f2c7 Mon Sep 17 00:00:00 2001 From: Marius Date: Tue, 27 Sep 2016 22:48:29 +0200 Subject: [PATCH] Add HookInvocationFinish event to logging --- cmd/tusd/cli/hooks.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/tusd/cli/hooks.go b/cmd/tusd/cli/hooks.go index e8ba5ff..7cb8d7f 100644 --- a/cmd/tusd/cli/hooks.go +++ b/cmd/tusd/cli/hooks.go @@ -51,10 +51,8 @@ func SetupPostHooks(handler *tusd.Handler) { func invokeHook(typ HookType, info tusd.FileInfo) { go func() { - _, err := invokeHookSync(typ, info, false) - if err != nil { - logEv("HookInvocationError", "type", string(typ), "id", info.ID, "error", err.Error()) - } + // Error handling is token care of by the function. + _, _ = invokeHookSync(typ, info, false) }() } @@ -100,10 +98,15 @@ func invokeHookSync(typ HookType, info tusd.FileInfo, captureOutput bool) ([]byt output, err = cmd.Output() } + if err != nil { + logEv("HookInvocationError", "type", string(typ), "id", info.ID, "error", err.Error()) + } else { + logEv("HookInvocationFinish", "type", string(typ), "id", info.ID) + } + // Ignore the error, only, if the hook's file could not be found. This usually // means that the user is only using a subset of the available hooks. if os.IsNotExist(err) { - logEv("HookInvocationError", "type", string(typ), "id", info.ID, "error", err.Error()) err = nil }