Skip to content
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

added support for NO_COLOR #586

Merged
merged 3 commits into from Sep 5, 2023
Merged

added support for NO_COLOR #586

merged 3 commits into from Sep 5, 2023

Conversation

Gaardsholt
Copy link
Contributor

This should fix #582

Signed-off-by: Lasse Gaardsholt <lasse.gaardsholt@bestseller.com>
Signed-off-by: Lasse Gaardsholt <lasse.gaardsholt@bestseller.com>
console.go Outdated
@@ -312,6 +312,11 @@ func needsQuote(s string) bool {

// colorize returns the string s wrapped in ANSI code c, unless disabled is true.
func colorize(s interface{}, c int, disabled bool) string {
e := os.Getenv("NO_COLOR")
if e == "true" {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GNU libtextstyle doc says:

The environment variable NO_COLOR can be used to suppress styling in the textual output. When this environment variable is set (to any value), libtextstyle-enabled programs will not emit colors and other text styling.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh you are right, fixed the code now.

Signed-off-by: Lasse Gaardsholt <lasse.gaardsholt@bestseller.com>
@Gaardsholt Gaardsholt requested a review from rs September 4, 2023 19:29
@rs rs merged commit 1bac5cc into rs:master Sep 5, 2023
5 checks passed
@Gaardsholt Gaardsholt deleted the no_color branch September 6, 2023 10:56
madkins23 pushed a commit to madkins23/zerolog that referenced this pull request Mar 2, 2024
* added support for NO_COLOR

Signed-off-by: Lasse Gaardsholt <lasse.gaardsholt@bestseller.com>

* added unit test for `NO_COLOR`

Signed-off-by: Lasse Gaardsholt <lasse.gaardsholt@bestseller.com>

* NO_COLOR can now be set to anything

Signed-off-by: Lasse Gaardsholt <lasse.gaardsholt@bestseller.com>

---------

Signed-off-by: Lasse Gaardsholt <lasse.gaardsholt@bestseller.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for NO_COLOR
2 participants