Last active
June 24, 2020 17:46
-
-
Save ideepu/02e1b2049ebddc7d4595e5f8785a07a4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
host_log="/home/pradeep/scripts" | |
install_log="$host_log/tmp.log" | |
# Color logging | |
log() { | |
# Color Logging | |
RED="\033[1;31m" # ERROR | |
GREEN="\033[1;32m" # INFO | |
YELLOW="\033[33;33m" # WARN | |
BLUE='\e[0;34m' # DEBUG | |
NOCOLOR="\033[0m" | |
ts=$(date "+%Y-%m-%d %H:%M:%S") | |
if [[ "$1" == "INFO" ]]; then | |
prefix="$ts ${GREEN}INFO: " | |
elif [[ "$1" == "ERROR" ]]; then | |
prefix="$ts ${RED}ERROR: " | |
elif [[ "$1" == "WARN" ]]; then | |
prefix="$ts ${YELLOW}WARN: " | |
elif [[ "$1" == "DEBUG" ]]; then | |
prefix="$ts ${BLUE}DEBUG: " | |
else | |
prefix="$ts ${GREEN}INFO: " | |
fi | |
suffix="${NOCOLOR}" | |
message="$prefix$2$suffix" | |
echo -e "$message" >> $install_log | |
} | |
log INFO "=== testing loggin script $host_mapr ===" | |
log WARN "=== testing loggin script $host_mapr ===" | |
log ERROR "=== testing loggin script $host_mapr ===" | |
log DEBUG "=== testing loggin script $host_mapr ===" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment