mirror of https://github.com/perkeep/perkeep.git
a6a3cac0df
This CL addresses issues #685 and #862. The general problem is that some critical errors, that lead clients such as camput to exit with failure, are not displayed when not running in verbose mode. The reason that happens is because of code such as: if *cmdmain.FlagVerbose { log.SetOutput(cmdmain.Stderr) } else { log.SetOutput(ioutil.Discard) } which means that in non-verbose mode we discard absolutely all log messages, even those that would be printed during a Fatal* call. To address that problem, we introduce a logger, as well as the Printf and Logf functions using it, in pkg/cmdmain. These two functions only output when *cmdmain.FlagVerbose is true. Commands such as camput or camtool should now always: 1) log.SetOutput(cmdmain.Stderr) in init(). 2) use log.Printf for messages that should always be printed. 3) use cmdmain.Printf/Logf for messages that should only be printed when *cmdmain.FlagVerbose is true. 4) use log.Fatal for critical errors. 5) optionally, set the Verbose and Logger of the client(s) they are using. Also, camput and camtool are now relying on the global -verbose flag from cmdmain, instead of having to define one for each subcommand. fixes #685 fixes #862 Change-Id: I088032fd28184a201076097bf878894b22a8a120 |
||
---|---|---|
.. | ||
.gitignore | ||
cammount.go | ||
cammount_other.go | ||
doc.go |