[fix:10]更新日志格式

This commit is contained in:
2020-09-13 00:26:59 +08:00
parent 56f7eac26f
commit 088c7d2aaf
+8 -3
View File
@@ -2,8 +2,6 @@
# Ver: 1.1 by Endial Fang (endial@126.com)
#[[ ${ENV_DEBUG:-false} = true ]] && set -x
set +x
MODULE="$(basename "$0")"
RESET='\033[0m'
@@ -41,7 +39,14 @@ stderr_print() {
# $1 - 日志类型
# $2 - 日志信息
LOG() {
stderr_print "${CYAN}${APP_NAME:-}${ENV_DEBUG:+:${MODULE:-} ${MAGENTA}$(date "+%T.%2N")}${RESET} ${*}"
local -r bool="${ENV_DEBUG:-false}"
shopt -s nocasematch
if [[ "$bool" = 1 || "$bool" =~ ^(yes|true)$ ]]; then
debugInfo="${CYAN}${APP_NAME:-}:${MODULE:-}"
else
debugInfo="${CYAN}${APP_NAME:-}"
fi
stderr_print "${debugInfo} ${MAGENTA}$(date "+%T")}${RESET} ${*}"
}
# 输出调试类日志信息,尽量少使用