sh/bash/log.sh

21 lines
599 B
Bash
Raw Normal View History

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
2023-05-14 21:24:40 +00:00
LOG_LEVEL=${LOG_LEVEL_WARN}
2023-05-14 13:51:38 +00:00
2024-11-11 19:33:23 +00:00
log_fatal() { [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_FATAL}" ] && echo "${@}" ; }
2023-05-14 13:51:38 +00:00
2024-11-11 19:33:23 +00:00
log_error() { [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_ERROR}" ] && echo "${@}" ; }
2023-05-14 13:51:38 +00:00
2024-11-11 19:33:23 +00:00
log_warn() { [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_WARN}" ] && echo "${@}" ; }
2023-05-14 13:51:38 +00:00
2024-11-11 19:33:23 +00:00
log_info() { [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_INFO}" ] && echo "${@}" ; }
2023-05-14 13:51:38 +00:00
2024-11-11 19:33:23 +00:00
log_debug() { [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_DEBUG}" ] && echo "${@}" ; }
2023-05-14 13:51:38 +00:00
2024-11-11 19:33:23 +00:00
log_trace() { [ "${LOG_LEVEL}" -ge "${LOG_LEVEL_TRACE}" ] && echo "${@}" ; }