2023-05-14 13:51:38 +00:00
|
|
|
LOG_LEVEL_FATAL=0
|
|
|
|
LOG_LEVEL_ERROR=1
|
|
|
|
LOG_LEVEL_WARN=2
|
|
|
|
LOG_LEVEL_INFO=3
|
|
|
|
LOG_LEVEL_DEBUG=4
|
|
|
|
LOG_LEVEL_TRACE=5
|
|
|
|
|
2024-11-12 06:20:25 +00:00
|
|
|
LOG_LEVEL=${LOG_LEVEL_INFO}
|
2023-05-14 13:51:38 +00:00
|
|
|
|
2024-11-12 06:20:25 +00:00
|
|
|
log_debug() {
|
|
|
|
if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_DEBUG}" ]; then
|
2024-11-13 11:08:04 +00:00
|
|
|
echo "[DEBUG]" "${@}"
|
2024-11-12 06:20:25 +00:00
|
|
|
fi
|
|
|
|
}
|
2023-05-14 13:51:38 +00:00
|
|
|
|
2024-11-12 06:20:25 +00:00
|
|
|
log_error() {
|
|
|
|
if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_ERROR}" ]; then
|
2024-11-13 11:08:04 +00:00
|
|
|
echo "[ERROR]" "${@}"
|
2024-11-12 06:20:25 +00:00
|
|
|
fi
|
|
|
|
}
|
2023-05-14 13:51:38 +00:00
|
|
|
|
2024-11-12 06:20:25 +00:00
|
|
|
log_fatal() {
|
|
|
|
if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_FATAL}" ]; then
|
2024-11-13 11:08:04 +00:00
|
|
|
echo "[FATAL]" "${@}"
|
2024-11-12 06:20:25 +00:00
|
|
|
fi
|
|
|
|
}
|
2023-05-14 13:51:38 +00:00
|
|
|
|
2024-11-12 06:20:25 +00:00
|
|
|
log_info() {
|
|
|
|
if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_INFO}" ]; then
|
|
|
|
echo "${@}"
|
|
|
|
fi
|
|
|
|
}
|
2023-05-14 13:51:38 +00:00
|
|
|
|
2024-11-12 06:20:25 +00:00
|
|
|
log_trace() {
|
|
|
|
if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_TRACE}" ]; then
|
2024-11-13 11:08:04 +00:00
|
|
|
echo "[TRACE]" "${@}"
|
2024-11-12 06:20:25 +00:00
|
|
|
fi
|
|
|
|
}
|
2023-05-14 13:51:38 +00:00
|
|
|
|
2024-11-12 06:20:25 +00:00
|
|
|
log_warn() {
|
|
|
|
if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_WARN}" ]; then
|
2024-11-13 11:08:04 +00:00
|
|
|
echo " [WARN]" "${@}"
|
2024-11-12 06:20:25 +00:00
|
|
|
fi
|
|
|
|
}
|