-
-
Save kevinguto/08120f40987e41b6039e706c564dbfa2 to your computer and use it in GitHub Desktop.
Colorize Tomcat
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
#!/bin/bash | |
# ABOUT | |
# Add color to your Catalina output logs for [info, warn, error, severe, startup] | |
# - This isn't the smartest, so if there is a match for any of the listed statuses in an | |
# output you can bet it'll be colorized | |
# USAGE | |
# catalina run 2>&1 | bash ~/colorize-tomcat-logs.sh | |
success=$(tput bold;tput setaf 2) | |
successCondition=*INFO:" "Server" "startup* | |
info=$(tput setaf 6) | |
infoCondition=*INFO* | |
warn=$(tput setaf 3) | |
warnCondition=*WARN* | |
error=$(tput setaf 1) | |
errorCondition=*ERROR* | |
severe=$(tput bold;tput setaf 1) | |
severeCondition=*SEVERE* | |
default=$(tput sgr0) | |
while read line; do | |
if [[ $line == $successCondition ]] | |
then | |
echo $line | sed -e "s/\($1\)/$success/" | |
elif [[ $line == $infoCondition ]] | |
then | |
echo $line | sed -e "s/\($1\)/$info/" | |
elif [[ $line == $warnCondition ]] | |
then | |
echo $line | sed -e "s/\($1\)/$warn/" | |
elif [[ $line == $errorCondition ]] | |
then | |
echo $line | sed -e "s/\($1\)/$error/" | |
elif [[ $line == $severeCondition ]] | |
then | |
echo $line | sed -e "s/\($1\)/$severe/" | |
else | |
echo $line | |
fi | |
printf $(tput sgr0) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment