Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ZeroDragon
Last active December 23, 2015 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZeroDragon/6676563 to your computer and use it in GitHub Desktop.
Save ZeroDragon/6676563 to your computer and use it in GitHub Desktop.
A small bash script to add syntax colors to a php.log
#!/bin/bash
func (){
local BLACK=`echo -en '\e[30m'`
local RED=`echo -en '\e[31m'`
local GREEN=`echo -en '\e[32m'`
local YELLOW=`echo -en '\e[33m'`
local BLUE=`echo -en '\e[34m'`
local MAGENTA=`echo -en '\e[35m'`
local CYAN=`echo -en '\e[36m'`
local WHITE=`echo -en '\e[37m'`
local RESET=`echo -en '\e[00m'`
local GREP=""
GREP="$GREP s/(\[|.*\])/$YELLOW\1$RESET/g;"
GREP="$GREP s/(\[33m\[)(.*)(UTC\])/$MAGENTA\2$RESET/g;"
GREP="$GREP s/(\(|\))/$BLUE\1$RESET/g;"
GREP="$GREP s/(Array|stdClass Object)/$BLUE\1$RESET/g;"
GREP="$GREP s/(=>)/$GREEN\1$RESET/g"
tail -f /path/to/your/php_error.log | sed -E $GREP
}
func
@ZeroDragon
Copy link
Author

Here is a Before and After screenshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment