Commit Graph

4 Commits

Author SHA1 Message Date
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
Brad Fitzpatrick ca58231336 camtool: remove duplicated code
Change-Id: I2009b132a1c10e60132333b9942aa4b5943b3932
2014-02-09 15:48:07 -08:00
mpl 1db2e7eaf3 pkg/client: auth and (camtool) TLS fixes
1) disallow auth from env when not in dev mode or on android
2) allow insecureTLS with flag in debug mode
3) set transport so that insecureTLS or trustedCert modes work

http://camlistore.org/issue/325

Change-Id: I6d8056bb75ffff5f002dfe9bd631ae996dc4e5ef
2014-01-09 11:23:40 -08:00
mpl 2588ff8c83 camtool: apparently forgot to add index.go in 2d85e017ff
Change-Id: I6b7ce9e70b15d622935950ac8b1f06d843590659
2013-12-29 00:03:58 +01:00