-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure --no-color
applies to all Supervisor output
#4334
Conversation
Thanks for the pull request! Here is what will happen next:
Thank you for contributing! |
cc: @bixu |
// | ||
// There is currently no short option to check; just the long | ||
// name. | ||
if args.contains(&String::from("--no-color")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems redundant and could be simplified
if args.contains("--no-color") {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@georgemarshall Sadly, no 😦 : rust-lang/rust#42671
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow
In several places we were directly embedding ANSI color codes in a log message as a way to emphasize certain parts of that message. However, this bypasses the existing controls we have over whether or not to colorize the Supervisor's output; regardless of your settings, these emphasized parts would *always* be colored. As an initial step to bring colored output under control, we are simply removing all these embedded "emphasis colors". A possible long-term solution would be to introduce a minimal templating language of sorts that allows us to mark particular bits of text for emphasis of one kind or another, allowing the final formatting of a message to be handled centrally. Think of an HTML/CSS-style separation of concerns, but for fancy colored log output. Signed-off-by: Christopher Maier <[email protected]>
Signed-off-by: Christopher Maier <[email protected]>
The `core::output` colorization logic hinges on the value of a global atomic variable. However, the Launcher is a separate process from the Supervisor; any value set in the Supervisor is completely distinct from what the Launcher sees. As a result, the Launcher would *always* colorize output, because colorization currently defaults to `true`. Since the Launcher always has access to the arguments used to start the Supervisor, and since there is only a single option we care about here, it's a simple matter to just check if a `--no-color` argument was passed and then take action accordingly. There's no need to bring `clap` in for something like this. Signed-off-by: Christopher Maier <[email protected]>
Just cuts down on repetition Signed-off-by: Christopher Maier <[email protected]>
We were using `UI::default()` everywhere, which doesn't honor the `--no-color` flag. We still have two different mechanisms governing output (our `output` module and our `ui` module), and should try and unify those as much as is practical. In the meantime, however, we can bridge the gap here. Signed-off-by: Christopher Maier <[email protected]>
e2e5c11
to
1f24903
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, pretty straight forward. In the new year we can look into how to support (re)colorizing some messaging but in a way that is reactive to the environment and wishes of a user.
Merge when ready!
}; | ||
|
||
let isatty = if env::var(NONINTERACTIVE_ENVVAR) | ||
// Keep string boolean for backwards-compatibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not exactly backwards-compatibility, it's current 😄
@@ -372,7 +371,7 @@ impl CfgRenderer { | |||
cfg_dest.display() | |||
); | |||
outputln!(preamble ctx.svc.group, "Updated {} {}", | |||
Purple.bold().paint(template.as_str()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Purple, wow, we were using all the colors!
@thesentinels approve |
🤘 I am testing your branch against master before merging it. We do this to ensure that the master branch is never failing tests. |
Travis CI has started testing this PR. |
💖 Travis CI reports this PR passed. It always makes me feel nice when humans approve of one anothers work. I'm merging this PR now. I just want you and the contributor to answer me one question: |
This should ensure that the
--no-color
option truly does eliminate all ANSI color codes from Supervisor output (note that this does not apply to any ANSI codes that might be present in the output of any supervised services).There are a few key points:
We were embedding color codes directly in log messages to emphasize certain parts. This was done in a way that completely bypassed any
--no-color
option; the color would always be there.The Launcher is responsible for routing standard output and error from supervised services, and uses our core output library. However, that library is currently driven by a global variable that is not set in the Launcher (because it's a completely separate process). Now, we ensure that the Launcher uses whatever colorization option is specified by the Supervisor
Some places in the Supervisor commands were using the
UI::default()
function to set up their outputs, but this does not honor the--no-color
option. Now, all uses ofUI
in the Supervisor commands goes through a common setup function that does honor this option.Starting up the Supervisor with
--no-color
now should truly configure things so there is no colored output. Future work still exists, though, including but not limited to:--no-color
the default behavior for non-interactive usesFurther details are in the commit messages.
Note that for users to fully experience this, a new Launcher package will need to be built and promoted.
Fixes #997