Skip to content

Add option to output plain logs without color codes.

Description

I'm deploying my runners in containers on Amazon's ECS service and piping the logs to CloudWatch via the Docker awslogs driver. CloudWatch doesn't support ANSI color codes, which makes it extremely difficult to decipher the actual log statements because the color codes are included like this:

[37;1mDocker Machine Details [0;m [37;1mcreating[0;m=1 [37;1midle[0;m=0 [37;1mmaxMachines[0;m=0 [37;1mminIdleCount[0;m=0 [37;1mremoving[0;m=0 [37;1mrunner[0;m=cba31e28 [37;1mtime[0;m=2016-12-07 20:33:58.255101069 +0000 UTC [37;1mtotal[0;m=1 [37;1mused[0;m=0

I think this would be a problem for nearly all log collection systems that aren't running in a terminal.

Proposal

Add an option to disable colorized log output.

EDIT -- 2016-12-13

I did a bit more research on this and it appears logrus is the culprit.

When running in the Docker container, logs are written to stdout and pumped to CloudWatch by the awslogs driver. logrus' TextFormatter thinks it is writing to a TTY so outputs color codes. I'm not sure if there's a configuration option in logrus to prevent this behavior that you can expose via CLI option or, an even better solution, add an option to use the JsonFormatter so logs can be pumped into logstash, splunk, or any other log analysis platform for easy ingest.

Edited by 🤖 GitLab Bot 🤖