From 571bc4df7590d5bf761db6b636bf53b01d95a27a Mon Sep 17 00:00:00 2001 From: Marius Date: Tue, 13 Aug 2019 10:51:03 +0200 Subject: [PATCH] cli: Add flag to reduce verbosity of output --- cmd/tusd/cli/flags.go | 2 ++ cmd/tusd/cli/hooks.go | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/tusd/cli/flags.go b/cmd/tusd/cli/flags.go index 3aa1e00..e39ddbd 100644 --- a/cmd/tusd/cli/flags.go +++ b/cmd/tusd/cli/flags.go @@ -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() diff --git a/cmd/tusd/cli/hooks.go b/cmd/tusd/cli/hooks.go index aadbd79..6c36651 100644 --- a/cmd/tusd/cli/hooks.go +++ b/cmd/tusd/cli/hooks.go @@ -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) }