Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Disable color in log output #415

Closed
PierreF opened this issue Jan 22, 2018 · 1 comment · Fixed by #416
Closed

Disable color in log output #415

PierreF opened this issue Jan 22, 2018 · 1 comment · Fixed by #416

Comments

@PierreF
Copy link
Contributor

PierreF commented Jan 22, 2018

Submission type

Request for enhancement (RFE)

Environment

Anything where log is not shown on a terminal

Stolon version

master

Additional environment information if useful to understand the bug

I'm using stolon inside a kubernetes with logs sent to Elasticsearch using fluentd (logs from container) and shown using Kibana

Enhancement Description

Logging is forcefully using color in the output. This work well when show directly in a terminal, not with any other method (e.g. "| less" or in Kibana).
When using another method, the escape sequence are shown: "�[34mINFO�[0m proxy/proxy.go:275 proxying to master address[...]"

I think this is important, as using Elasticsearch/Kibana is a common setup in Kubernetes and those escape sequence make the log less readable.
Even worse, when using ElasticSearch/Kibana, that means that the search string "error" won't match "[31mERROR�[0m sentinel/sentinel.go:274[...]" because by default is search for the word error (here the word is 31mERROR).

I could think of 3 ways to fix this:

  • Do some guessing, if attached to a tty use color, if not don't use color (I don't like that solution, seems fragile)
  • Always disable color
  • Add an option to disable color in output

I could try to come with a PR, just need to know which solution should be done :)

@sgotti
Copy link
Member

sgotti commented Jan 22, 2018

@PierreF Uh! I was quite sure that this was already handled by zap but looks like I was wrong. If so this should be definitely handled.

Other logging libraries use tty detection (for example we could use https://github.com/mattn/go-isatty) but I'll also add an option to explicitly disable colored output.

A PR will be really appreciated. If you don't have time I'll do it by myself.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants