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() {
|
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
|
if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_ERROR}" ]; then
|
||||||
echo "[ERROR]" "${@}" >&2
|
echo "[ERROR]" "${@}" >&2
|
||||||
|
return "${code}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
sh_log_fatal() {
|
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
|
if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_FATAL}" ]; then
|
||||||
echo "[FATAL]" "${@}" >&2
|
echo "[FATAL]" "${@}" >&2
|
||||||
|
exit "${code}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue