Skip to content

Commit

Permalink
fix: log format
Browse files Browse the repository at this point in the history
  • Loading branch information
adoyle-h committed Jun 9, 2023
1 parent 9bf46e7 commit 1d29d02
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 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="$*"
echo "$msg" >&2
printf "[%s][ERROR][$tag] %s\n" "$(date +"%Y-%m-%d %H:%M:%S")" "$msg" &>> "$ONE_LOG_FILE"
printf "[%s][ERROR][$tag] %s\n" "$(date +"%Y-%m-%d %H:%M:%S")" "$msg" | tee -a "$ONE_LOG_FILE" >&2
}

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

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

log_verb() {
printf "[%s][VERB][$1] %s\n" "$(date +"%Y-%m-%d %H:%M:%S")" "$2" &>> "$ONE_LOG_FILE"
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"
}

0 comments on commit 1d29d02

Please sign in to comment.