Add --verbose flag and move some startup routine output to it.#9
Add --verbose flag and move some startup routine output to it.#9
Conversation
febbraro
left a comment
There was a problem hiding this comment.
Some commands like rig status use stdout for all of their output. So currently, status outputs nothing. As part of this branch we can make status return "Running" or "Stopped" and verbose can output the whole table of data, if we want. We should evaluate the rest of the commands to determine if they all function with appropriate output when in a "info" setting vs. verbose.
|
Hm, that's a bit tricky. The current change just switches the commands to output only if verbose is set, but does not address alternate processing if it isn't set. There are a couple different ways we could address this: Option 1: Alter StreamCommand()We add a second command parameter to StreamCommand to run if verbose mode is active, and let the caller construct different behaviors depending on the required verbosity. I don't like this as it limits the logic to the code we are executing. Option 2: Capture command output and returnCurrent StreamCommand runs the command and returns the error. If we switch to use cmd.Output() instead we can return the output or the error. This means that the caller can evaluate the current state of verbosity and process what to exec or output on it's own. I think this one is better, but a bit more involved. |
* origin/develop: Removed the need for cgo compilation flag Disambiguate docker-compose build from docker-compose run build. Fixed #7: Docker-based development of Rig.
|
Okay, pushed some changes.
|
cli/util/logger.go
Outdated
| Warning: log.New(os.Stdout, color.YellowString("[WARN] "), 0), | ||
| Error: log.New(os.Stderr, color.RedString("[ERROR] "), 0), | ||
| Verbose: log.New(verboseWriter, "[VERBOSE] ", 0), | ||
| IsVerbose: verbose, |
|
|
||
| func Logger() *RigLogger { | ||
| if logger == nil { | ||
| LoggerInit(false) |
There was a problem hiding this comment.
Why passing in false here?
There was a problem hiding this comment.
Well, I can;t imagine a case where the logger is nil, but just in case it is, we dont have access to the cli.Context to see if the GlobalFlag verbose is set. So, in lieu of information, lets use default behavior, which is not verbose. Does that make sense? I can also log a warning message about it. :)
… dashboard containers
This reduces the amount of noise produced by default when running
rig start. If you want to see all the details, there is stillrig --verbose start, or settingRIG_VERBOSE=1as an environment variable. It might be I was too aggressive, worth reviewing.One consideration, I'm thinking we might want a second level of verbosity within which to print out the commands ~
out.Learning.Println(cmd.Path, cmd.Args). That piece is captured in #5.This fixes #4.