log/prefix

This commit is contained in:
Marc Beninca 2024-11-13 12:08:04 +01:00
parent f332104d12
commit dae14f780e
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -9,19 +9,19 @@ LOG_LEVEL=${LOG_LEVEL_INFO}
log_debug() { log_debug() {
if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_DEBUG}" ]; then if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_DEBUG}" ]; then
echo "${@}" echo "[DEBUG]" "${@}"
fi fi
} }
log_error() { log_error() {
if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_ERROR}" ]; then if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_ERROR}" ]; then
echo "${@}" echo "[ERROR]" "${@}"
fi fi
} }
log_fatal() { log_fatal() {
if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_FATAL}" ]; then if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_FATAL}" ]; then
echo "${@}" echo "[FATAL]" "${@}"
fi fi
} }
@ -33,12 +33,12 @@ log_info() {
log_trace() { log_trace() {
if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_TRACE}" ]; then if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_TRACE}" ]; then
echo "${@}" echo "[TRACE]" "${@}"
fi fi
} }
log_warn() { log_warn() {
if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_WARN}" ]; then if [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_WARN}" ]; then
echo "${@}" echo " [WARN]" "${@}"
fi fi
} }