Skip to content

Commit

Permalink
fix: add color to logs
Browse files Browse the repository at this point in the history
  • Loading branch information
adoyle-h committed Apr 2, 2024
1 parent 7f61d21 commit 3ec0acd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bash/log.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ log_err() {
local tag=$1
shift 1
local msg="$*"
printf "[%s][ERROR][$tag] %s\n" "$(date +"%Y-%m-%d %H:%M:%S")" "$msg" | tee -a "$ONE_LOG_FILE" >&2
printf "%b[%s][ERROR][$tag] %s%b\n" "$RED" "$(date +"%Y-%m-%d %H:%M:%S")" "$msg" "$RESET_ALL" | tee -a "$ONE_LOG_FILE" >&2
}

log_warn() {
local tag=$1
shift 1
local msg="$*"
printf "[%s][WARN][$tag] %s\n" "$(date +"%Y-%m-%d %H:%M:%S")" "$msg" | tee -a "$ONE_LOG_FILE" >&2
printf "%b[%s][WARN][$tag] %s%b\n" "$YELLOW" "$(date +"%Y-%m-%d %H:%M:%S")" "$msg" "$RESET_ALL" | tee -a "$ONE_LOG_FILE" >&2
}

log_info() {
local tag=$1
shift 1
local msg="$*"
printf "[%s][INFO][$tag] %s\n" "$(date +"%Y-%m-%d %H:%M:%S")" "$msg" | tee -a "$ONE_LOG_FILE" >&2
printf "[%s][INFO][$tag] %s\n" "$(date +"%Y-%m-%d %H:%M:%S")" "$msg" "$RESET_ALL" | tee -a "$ONE_LOG_FILE" >&2
}

log_verb() {
local tag=$1
shift 1
local msg="$*"
printf "[%s][VERB][$tag] %s\n" "$(date +"%Y-%m-%d %H:%M:%S")" "$msg" | tee -a "$ONE_LOG_FILE" >&2
printf "%b[%s][VERB][$tag] %s%b\n" "$GREY" "$(date +"%Y-%m-%d %H:%M:%S")" "$msg" "$RESET_ALL" | tee -a "$ONE_LOG_FILE" >&2
}

0 comments on commit 3ec0acd

Please sign in to comment.