codes
This commit is contained in:
parent
2089e8c1e0
commit
fbe30920d7
1 changed files with 8 additions and 0 deletions
|
@ -16,14 +16,22 @@ sh_log_debug() {
|
|||
}
|
||||
|
||||
sh_log_error() {
|
||||
local code="${1}"
|
||||
shift
|
||||
[ -n "${code}" ] || sh_log_fatal 1 "No error code"
|
||||
if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_ERROR}" ]; then
|
||||
echo "[ERROR]" "${@}" >&2
|
||||
return "${code}"
|
||||
fi
|
||||
}
|
||||
|
||||
sh_log_fatal() {
|
||||
local code="${1}"
|
||||
shift
|
||||
[ -n "${code}" ] || sh_log_fatal 1 "No error code"
|
||||
if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_FATAL}" ]; then
|
||||
echo "[FATAL]" "${@}" >&2
|
||||
exit "${code}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue