perkeep/cmd/camtool
mpl a6a3cac0df cmd/*: always output on fatal errors
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
2017-10-19 02:22:44 +02:00
..
.gitignore camdebug moved as camtool debug 2013-02-23 00:53:03 +01:00
camtool.go cmd/*: always output on fatal errors 2017-10-19 02:22:44 +02:00
claims.go Implemented an optional parameter (attr) in 'camtool claims' to filter by claim type 2014-03-19 00:45:51 -03:00
dbinit.go Move remaining stuff in third_party/* to vendor/* 2016-04-20 16:49:15 -07:00
debug.go camtool: added gsinit, was cmd/camgsinit. Better help too. 2013-02-26 14:45:49 +01:00
describe.go cmd/camtool: add basic describe --at flag 2016-04-24 08:46:40 -07:00
disco.go pkg/client: wire up http2 support, unexported Client.InsecureTLS 2015-12-29 11:33:38 -08:00
doc.go add canonical import paths 2016-03-13 19:57:14 -07:00
dp_idx_rebuild.go Delete misc unused objects 2016-04-06 17:59:51 +02:00
dumpconfig.go Move GCE stuff out of camlistored into new package. Use from camtool. 2014-08-07 12:33:52 -07:00
env.go camtool: add env camsrcroot 2014-01-31 12:21:04 +01:00
exif.go vendor: move pkg/images dependencies from third_party 2015-12-18 22:15:33 +01:00
googinit.go vendor: rename google.golang.org/cloud to cloud.google.com/go 2016-09-08 15:14:12 +02:00
index.go cmd/*: always output on fatal errors 2017-10-19 02:22:44 +02:00
list.go cmd/*: always output on fatal errors 2017-10-19 02:22:44 +02:00
makestatic.go Fix deadlock in search/index. 2016-04-22 14:57:10 -07:00
mime.go More docs. Every package is documented now. 2013-07-07 21:12:30 -07:00
packblobs.go camtool: fix packblobs usage 2015-01-19 15:09:07 -08:00
search.go camtool search: added -continue flag to complement -limit 2016-04-17 18:52:53 +00:00
searchdoc.go search: Self-documenting atoms 2014-05-15 00:42:32 +02:00
splits.go camdebug moved as camtool debug 2013-02-23 00:53:03 +01:00
sqlite_cond.go Move remaining stuff in third_party/* to vendor/* 2016-04-20 16:49:15 -07:00
sync.go cmd/*: always output on fatal errors 2017-10-19 02:22:44 +02:00
sync_test.go camtool sync: local path support on Windows 2016-01-11 12:00:37 +01:00