log/constants

This commit is contained in:
Marc Beninca 2024-11-18 12:07:42 +01:00
parent 3b0f3c14c1
commit b68d4746e6
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -1,44 +1,44 @@
LOG_LEVEL_FATAL=0 SH_LOG_LEVEL_FATAL=0
LOG_LEVEL_ERROR=1 SH_LOG_LEVEL_ERROR=1
LOG_LEVEL_WARN=2 SH_LOG_LEVEL_WARN=2
LOG_LEVEL_INFO=3 SH_LOG_LEVEL_INFO=3
LOG_LEVEL_DEBUG=4 SH_LOG_LEVEL_DEBUG=4
LOG_LEVEL_TRACE=5 SH_LOG_LEVEL_TRACE=5
LOG_LEVEL=${LOG_LEVEL_INFO} SH_LOG_LEVEL=${SH_LOG_LEVEL_INFO}
log_debug() { log_debug() {
if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_DEBUG}" ]; then if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_DEBUG}" ]; then
echo "[DEBUG]" "${@}" echo "[DEBUG]" "${@}"
fi fi
} }
log_error() { log_error() {
if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_ERROR}" ]; then if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_ERROR}" ]; then
echo "[ERROR]" "${@}" echo "[ERROR]" "${@}"
fi fi
} }
log_fatal() { log_fatal() {
if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_FATAL}" ]; then if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_FATAL}" ]; then
echo "[FATAL]" "${@}" echo "[FATAL]" "${@}"
fi fi
} }
log_info() { log_info() {
if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_INFO}" ]; then if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_INFO}" ]; then
echo "${@}" echo "${@}"
fi fi
} }
log_trace() { log_trace() {
if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_TRACE}" ]; then if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_TRACE}" ]; then
echo "[TRACE]" "${@}" echo "[TRACE]" "${@}"
fi fi
} }
log_warn() { log_warn() {
if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_WARN}" ]; then if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_WARN}" ]; then
echo " [WARN]" "${@}" echo " [WARN]" "${@}"
fi fi
} }