cli: Add flag to reduce verbosity of output
This commit is contained in:
parent
31d31ba3b9
commit
571bc4df75
|
@ -30,6 +30,7 @@ var Flags struct {
|
||||||
ExposeMetrics bool
|
ExposeMetrics bool
|
||||||
MetricsPath string
|
MetricsPath string
|
||||||
BehindProxy bool
|
BehindProxy bool
|
||||||
|
VerboseOutput bool
|
||||||
|
|
||||||
FileHooksInstalled bool
|
FileHooksInstalled bool
|
||||||
HttpHooksInstalled bool
|
HttpHooksInstalled bool
|
||||||
|
@ -59,6 +60,7 @@ func ParseFlags() {
|
||||||
flag.BoolVar(&Flags.ExposeMetrics, "expose-metrics", true, "Expose metrics about tusd usage")
|
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.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.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()
|
flag.Parse()
|
||||||
|
|
||||||
|
|
|
@ -103,14 +103,16 @@ func invokeHookSync(typ hooks.HookType, info tusd.FileInfo, captureOutput bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
name := string(typ)
|
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)
|
output, returnCode, err := hookHandler.InvokeHook(typ, info, captureOutput)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logEv(stderr, "HookInvocationError", "type", string(typ), "id", info.ID, "error", err.Error())
|
logEv(stderr, "HookInvocationError", "type", string(typ), "id", info.ID, "error", err.Error())
|
||||||
MetricsHookErrorsTotal.WithLabelValues(string(typ)).Add(1)
|
MetricsHookErrorsTotal.WithLabelValues(string(typ)).Add(1)
|
||||||
} else {
|
} else if Flags.VerboseOutput {
|
||||||
logEv(stdout, "HookInvocationFinish", "type", string(typ), "id", info.ID)
|
logEv(stdout, "HookInvocationFinish", "type", string(typ), "id", info.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue