Skip to content

Instantly share code, notes, and snippets.

@jbfarez
Created May 4, 2021 08:01
Show Gist options
  • Save jbfarez/b9db1bccafa72e39aa205200669d7673 to your computer and use it in GitHub Desktop.
Save jbfarez/b9db1bccafa72e39aa205200669d7673 to your computer and use it in GitHub Desktop.
Bash simple log function
logMe() {
local LIGHT_RED="\033[1;31m"
local LIGHT_GREEN="\033[1;32m"
local YELLOW="\033[0;33m"
local DELIM="\033[00m"
local LEVEL=$1
local MSG=$2
case ${LEVEL} in
info)
echo -e "${LIGHT_GREEN}[ info ]${DELIM} ${MSG}"
;;
warning)
echo -e "${YELLOW}[ warning ]${DELIM} ${MSG}"
;;
error)
echo -e "${LIGHT_RED}[ error ]${DELIM} ${MSG}"
;;
*)
echo -e "${LIGHT_RED}[ fatal ]${DELIM} logMe funciton called with a wrong argument"
;;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment