Colorize log file
Posted by mazet on Jul 01 2016 in Awk
Short script to colorize log file.
Shell
#!/usr/bin/awk -f | |
| |
# split glue line | |
BEGIN {start=":host[0-9][0-9]: "} | |
"^..*" start {$0=gensub("^(..*)(" start ")", "\\1\n\\2", "g")} | |
/^$/ {getline} | |
| |
# colorize line | |
/TRACE/ {$0="\033[1;34m" $0 "\033[0;0m"} # blue | |
/DEBUG/ {$0="\033[1;32m" $0 "\033[0;0m"} # green | |
/INFO/ {} | |
/WARN/ {$0="\033[1;33m" $0 "\033[0;0m"} # yellow | |
/ERROR/ {$0="\033[1;31m" $0 "\033[0;0m"} # red | |
| |
{print} |
This entry was posted by mazet and filed under Awk.