diff --git a/cmd/camput/camput.go b/cmd/camput/camput.go index 32c43a14e..b121032f9 100644 --- a/cmd/camput/camput.go +++ b/cmd/camput/camput.go @@ -64,9 +64,11 @@ func init() { if up := uploader; up != nil { up.Close() stats := up.Stats() - log.Printf("Client stats: %s", stats.String()) - if up.transport != nil { - log.Printf(" #HTTP reqs: %d", up.transport.Requests()) + if *cmdmain.FlagVerbose { + log.Printf("Client stats: %s", stats.String()) + if up.transport != nil { + log.Printf(" #HTTP reqs: %d", up.transport.Requests()) + } } } } diff --git a/pkg/cmdmain/cmdmain.go b/pkg/cmdmain/cmdmain.go index 0fabd9872..870fed6b9 100644 --- a/pkg/cmdmain/cmdmain.go +++ b/pkg/cmdmain/cmdmain.go @@ -41,8 +41,8 @@ var ( // ExtraFlagRegistration allows to add more flags from // other packages (with AddFlags) when Main starts. ExtraFlagRegistration = func() {} - // PreExit is meant to dump additional stats and other - // verbiage before Main terminates. + // PreExit runs after the subcommand, but before Main terminates + // with either success or the error from the subcommand. PreExit = func() {} // ExitWithFailure determines whether the command exits // with a non-zero exit status. @@ -278,9 +278,7 @@ func Main() { } Exit(1) } - if *FlagVerbose { - PreExit() - } + PreExit() if err != nil { if !ExitWithFailure { // because it was already logged if ExitWithFailure