cli: Add flag to reduce verbosity of output

This commit is contained in:
Marius 2019-08-13 10:51:03 +02:00
parent 31d31ba3b9
commit 571bc4df75
2 changed files with 6 additions and 2 deletions

View File

@ -30,6 +30,7 @@ var Flags struct {
ExposeMetrics bool
MetricsPath string
BehindProxy bool
VerboseOutput bool
FileHooksInstalled bool
HttpHooksInstalled bool
@ -59,6 +60,7 @@ func ParseFlags() {
flag.BoolVar(&Flags.ExposeMetrics, "expose-metrics", true, "Expose metrics about tusd usage")
flag.StringVar(&Flags.MetricsPath, "metrics-path", "/metrics", "Path under which the metrics endpoint will be accessible")
flag.BoolVar(&Flags.BehindProxy, "behind-proxy", false, "Respect X-Forwarded-* and similar headers which may be set by proxies")
flag.BoolVar(&Flags.VerboseOutput, "verbose", true, "Enable verbose logging output")
flag.Parse()

View File

@ -103,14 +103,16 @@ func invokeHookSync(typ hooks.HookType, info tusd.FileInfo, captureOutput bool)
}
name := string(typ)
logEv(stdout, "HookInvocationStart", "type", name, "id", info.ID)
if Flags.VerboseOutput {
logEv(stdout, "HookInvocationStart", "type", name, "id", info.ID)
}
output, returnCode, err := hookHandler.InvokeHook(typ, info, captureOutput)
if err != nil {
logEv(stderr, "HookInvocationError", "type", string(typ), "id", info.ID, "error", err.Error())
MetricsHookErrorsTotal.WithLabelValues(string(typ)).Add(1)
} else {
} else if Flags.VerboseOutput {
logEv(stdout, "HookInvocationFinish", "type", string(typ), "id", info.ID)
}