How do I "echo" a log message with a color?


#1

My circle.yml file is quite lean and just passes control on to a shell script that does most of the heavy lifting. Throughout the build/test/deploy/release processes I have a few log messages sprinkled throughout my shell script so that I can quickly scan through the CircleCI Build Summary to see what’s going on.

I would like these log messages to an easy to spot color, so they stand out. How do I do this?

I have tried (nearly?) all options listed here: http://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux but they don’t seem to work


#2

Hello @qthenu,

ANSI encoded color output should Just Work :tm:, as I’ve seen it work with rspec and cucumber.

Could you provide an example script you tried?


#3

Colored output from eg testing frameworks etc. works fine, but things I echo from my make file rules don’t. For example, consider

       @echo "$(ccso)$(ccgreen)Finished unit tests of console app$(ccend)"

where

ccend = $(shell tput sgr0)
ccbold = $(shell tput bold)
ccgreen = $(shell tput setaf 2)
ccso = $(shell tput smso)

These colorings work fine on my local terminal. In CI log output, they seem to be being ignored completely.


#4