-
-
Save tfga/26c22026d9aeb9c0df3db2b39ccfbf88 to your computer and use it in GitHub Desktop.
Colorize logs
This file contains 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 characters
#!/usr/bin/env bash | |
# | |
# Usage: | |
# | |
# catalina.sh run 2>&1 | colorizeTomcat | |
# tail -200 catalina.out | colorizeTomcat | |
# | |
# Previous versions: | |
# | |
# https://gist.github.com/masonwan/7956055 | |
# https://gist.github.com/ElMesa/374c556283972e96deef | |
# | |
colorizeLine() { | |
local color="$1" | |
local level="$2" | |
colorize "$color" "^.*$level.*" | |
} | |
colorize() { | |
local color="$1" | |
local level="$2" | |
ack-grep --flush --nopager --passthru --color --color-match="$color" "$level" | |
} | |
colorize red "ERROR" | \ | |
colorize red "SEVERE" | \ | |
colorize green "DEBUG" | \ | |
colorize yellow "Deploying|finished" | \ | |
colorize blue "INFO" | |
#################################################################### | |
# Colors available | |
# | |
# From Stackoverflow: http://stackoverflow.com/a/9626444 | |
# Thanks to Andy Lester: http://stackoverflow.com/users/8454/andy-lester | |
# Thanks to Mytho: http://stackoverflow.com/users/225037/mytho | |
#################################################################### | |
#The recognized normal foreground color attributes (colors 0 to 7) are: | |
# | |
# black red green yellow blue magenta cyan white | |
# | |
# The corresponding bright foreground color attributes (colors 8 to 15) | |
# are: | |
# | |
# bright_black bright_red bright_green bright_yellow | |
# bright_blue bright_magenta bright_cyan bright_white | |
# | |
# The recognized normal background color attributes (colors 0 to 7) are: | |
# | |
# on_black on_red on_green on_yellow | |
# on_blue on_magenta on_cyan on_white | |
# | |
# The recognized bright background color attributes (colors 8 to 15) are: | |
# | |
# on_bright_black on_bright_red on_bright_green on_bright_yellow | |
# on_bright_blue on_bright_magenta on_bright_cyan on_bright_white | |
# | |
# For any of the above listed attributes, case is not significant | |
#################################################################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment