Logging format updates - hurray!
This commit is contained in:
56
Okiru
56
Okiru
@@ -83,9 +83,17 @@ logging () {
|
||||
if [[ -n $VERBOSE ]]; then
|
||||
#Debugging level logging; can be toggled via a switch
|
||||
debug () {
|
||||
printf "${BLUE}[DEBUG]: $1${STOP}\n"
|
||||
if [[ -f $LOG ]]; then
|
||||
echo -e "$(date +"%T:%N") [DEBUG]: $1" >> $LOG
|
||||
if [[ -z $2 ]]; then
|
||||
printf "${PURPLE}$(date +"%T:%N")${STOP} ${BLUE}[DEBUG]: %s${STOP}\n" "$1"
|
||||
if [[ -f $LOG ]]; then
|
||||
echo -e "$(date +"%T:%N") [DEBUG]: $1" >> $LOG
|
||||
fi
|
||||
elif [[ -n $2 ]]; then
|
||||
printf "${PURPLE}$(date +"%T:%N")${STOP} ${BLUE}[DEBUG]: %s${STOP} ${LIGHT_BLUE}%s${STOP}\n" "$1" "$2"
|
||||
if [[ -f $LOG ]]; then
|
||||
echo -e "$(date +"%T:%N") [DEBUG]: $1" >> $LOG
|
||||
fi
|
||||
|
||||
fi
|
||||
}
|
||||
#Otherwise, ignore debug calls;
|
||||
@@ -97,32 +105,43 @@ fi
|
||||
#Information level logging;
|
||||
info () {
|
||||
if [[ -z $2 ]]; then
|
||||
printf "${CYAN}[INFO]:${STOP} %s\n" "$1"
|
||||
printf "${PURPLE}$(date +"%T:%N")${STOP} ${CYAN}[INFO]:${STOP} %s\n" "$1"
|
||||
if [[ -f $LOG ]]; then
|
||||
echo -e "$(date +"%T:%N") [INFO]: $1" >> $LOG
|
||||
fi
|
||||
elif [[ -n $2 ]]; then
|
||||
printf "${CYAN}[INFO]:${STOP} %s ${PURPLE}%s${STOP}\n" "$1" "$2"
|
||||
printf "${PURPLE}$(date +"%T:%N")${STOP} ${CYAN}[INFO]:${STOP} %s ${LIGHT_CYAN}%s${STOP}\n" "$1" "$2"
|
||||
if [[ -f $LOG ]]; then
|
||||
printf "$(date +"%T:%N")${CYAN}[INFO]:${STOP} %s ${PURPLE}%s${STOP}\n" "$1" "$2" >> $LOG
|
||||
printf "${PURPLE}$(date +"%T:%N")${CYAN}[INFO]:${STOP} %s ${LIGHT_CYAN}%s${STOP}\n" "$1" "$2" >> $LOG
|
||||
fi
|
||||
fi
|
||||
}
|
||||
#Warning level logging;
|
||||
warn () {
|
||||
printf "${YELLOW}[WARNING]:${STOP} $1\n"
|
||||
if [[ -f $LOG ]]; then
|
||||
echo -e "$(date +"%T:%N") [WARN]: $1" >> $LOG
|
||||
if [[ -z $2 ]]; then
|
||||
printf "${PURPLE}$(date +"%T:%N")${STOP} ${ORANGE}[WARNING]:${STOP} %s\n" "$1"
|
||||
if [[ -f $LOG ]]; then
|
||||
echo -e "$(date +"%T:%N") [WARN]: $1" >> $LOG
|
||||
fi
|
||||
elif [[ -n $2 ]]; then
|
||||
printf "${PURPLE}$(date +"%T:%N")${STOP} ${ORANGE}[WARNING]:${STOP} %s ${YELLOW}%s${STOP}\n" "$1" "$2"
|
||||
if [[ -f $LOG ]]; then
|
||||
echo -e "$(date +"%T:%N") [WARN]: $1" >> $LOG
|
||||
fi
|
||||
fi
|
||||
}
|
||||
#Error logging function; Errors are added to an array and a report file.
|
||||
error () {
|
||||
printf "${RED}[ERROR]: $1${STOP}\n"
|
||||
# ^ Print it to the screen
|
||||
if [[ -z $2 ]]; then
|
||||
printf "${PURPLE}$(date +"%T:%N")${STOP} ${RED}[ERROR]: %s${STOP}\n" "$1"
|
||||
# ^ Print it to the screen
|
||||
elif [[ -n $2 ]]; then
|
||||
printf "${PURPLE}$(date +"%T:%N")${STOP} ${RED}[ERROR]: %s${STOP}${LIGHT_RED} %s${STOP}\n" "$1"
|
||||
fi
|
||||
errors+=("$1")
|
||||
# ^ And add to errors array
|
||||
if [[ -f $LOG ]]; then
|
||||
echo -e "$(date +"%T:%N") [ERROR]: $1" >> $LOG
|
||||
echo -e "$(date +"%T:%N") [ERROR]: $1" >> $LOG
|
||||
# ^ Log it with its' time and date
|
||||
fi
|
||||
if [[ -f $REPORT ]]; then
|
||||
@@ -132,9 +151,16 @@ error () {
|
||||
return 1
|
||||
}
|
||||
ok () {
|
||||
printf "${GREEN}[SUCCESS]: $1${STOP}\n"
|
||||
if [[ -f $LOG ]]; then
|
||||
echo -e "$(date +"%T:%N") [SUCCESS]: $1" >> $LOG
|
||||
if [[ -z $2 ]]; then
|
||||
printf "${PURPLE}$(date +"%T:%N")${STOP} ${GREEN}[SUCCESS]: %s${STOP}\n" "$1"
|
||||
if [[ -f $LOG ]]; then
|
||||
echo -e "$(date +"%T:%N") [SUCCESS]: $1" >> $LOG
|
||||
fi
|
||||
elif [[ -n $2 ]]; then
|
||||
printf "${PURPLE}$(date +"%T:%N")${STOP} ${GREEN}[SUCCESS]:${LIGHT_GREEN} %s${STOP}${GREEN} %s${STOP}\n" "$1" "$2"
|
||||
if [[ -f $LOG ]]; then
|
||||
echo -e "$(date +"%T:%N") [SUCCESS]: $1" >> $LOG
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user