Created
February 8, 2019 09:09
-
-
Save looztra/2fbba0464705b943ca53b21d9aec70ab to your computer and use it in GitHub Desktop.
Revisions
-
looztra created this gist
Feb 8, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ # Borrowed to someone, but I don't remember who it was, sorry :( # Print message $2 with log-level $1 to STDERR, colorized if terminal # log DEBUG "DOCKER_HOST ${DOCKER_HOST}" log() { local level=${1?} shift local code= line="[$(date '+%F %T')] $level: $*" if [ -t 2 ] then case "$level" in INFO) code=36 ;; DEBUG) code=35 ;; WARN) code=33 ;; ERROR) code=31 ;; *) code=37 ;; esac echo -e "\e[${code}m${line}\e[0m" else echo "$line" fi >&2 }