Skip to content

Instantly share code, notes, and snippets.

@JBlond
Last active December 20, 2023 19:40
Show Gist options
  • Select an option

  • Save JBlond/a14b3a4fb53f49dc7ea0c4fc751ed5a0 to your computer and use it in GitHub Desktop.

Select an option

Save JBlond/a14b3a4fb53f49dc7ea0c4fc751ed5a0 to your computer and use it in GitHub Desktop.

Revisions

  1. JBlond renamed this gist Sep 30, 2019. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions tailfc.sh → tailf-with-colors.sh
    Original file line number Diff line number Diff line change
    @@ -7,9 +7,11 @@ tailf-with-colors () {
    tail -f $1 | awk '
    {matched=0}
    /INFO:/ {matched=1; print "\033[0;37m" $0 "\033[0m"} # WHITE
    /NOTICE:/ {matched=1; print "\033[0;36m" $0 "\033[0m"} # CYAN
    /WARNING:/ {matched=1; print "\033[0;34m" $0 "\033[0m"} # BLUE
    /DEBUG:/ {matched=1; print "\033[0;37m" $0 "\033[0m"} # WHITE
    /NOTICE:/ {matched=1; print "\033[[1;32m" $0 "\033[0m"} # Light green
    /WARNING:/ {matched=1; print "\033[1;31m" $0 "\033[0m"} # Purple
    /ERROR:/ {matched=1; print "\033[0;31m" $0 "\033[0m"} # RED
    /CRITICAL:/ {matched=1; print "\033[0;31m" $0 "\033[0m"} # RED
    /ALERT:/ {matched=1; print "\033[0;35m" $0 "\033[0m"} # PURPLE
    matched==0 {print "\033[0;33m" $0 "\033[0m"} # YELLOW
    '
  2. JBlond created this gist Sep 3, 2019.
    16 changes: 16 additions & 0 deletions tailfc.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    tailf-with-colors () {
    if [ -z "$1" ] ; then
    echo "Please specify a file for monitoring"
    return
    fi

    tail -f $1 | awk '
    {matched=0}
    /INFO:/ {matched=1; print "\033[0;37m" $0 "\033[0m"} # WHITE
    /NOTICE:/ {matched=1; print "\033[0;36m" $0 "\033[0m"} # CYAN
    /WARNING:/ {matched=1; print "\033[0;34m" $0 "\033[0m"} # BLUE
    /ERROR:/ {matched=1; print "\033[0;31m" $0 "\033[0m"} # RED
    /ALERT:/ {matched=1; print "\033[0;35m" $0 "\033[0m"} # PURPLE
    matched==0 {print "\033[0;33m" $0 "\033[0m"} # YELLOW
    '
    }