From 2520fbee34b80b4576f2f42375cacd75eea9bab9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 14 May 2023 15:51:38 +0200 Subject: [PATCH] log --- bash/log.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 bash/log.sh diff --git a/bash/log.sh b/bash/log.sh new file mode 100644 index 0000000..1e699b3 --- /dev/null +++ b/bash/log.sh @@ -0,0 +1,20 @@ +LOG_LEVEL_FATAL=0 +LOG_LEVEL_ERROR=1 +LOG_LEVEL_WARN=2 +LOG_LEVEL_INFO=3 +LOG_LEVEL_DEBUG=4 +LOG_LEVEL_TRACE=5 + +LOG_LEVEL=${LOG_LEVEL_WARNING} + +function log_fatal { [ ${LOG_LEVEL} -ge ${LOG_LEVEL_FATAL} ] && echo "${@}" ; } + +function log_error { [ ${LOG_LEVEL} -ge ${LOG_LEVEL_ERROR} ] && echo "${@}" ; } + +function log_warn { [ ${LOG_LEVEL} -ge ${LOG_LEVEL_WARN} ] && echo "${@}" ; } + +function log_info { [ ${LOG_LEVEL} -ge ${LOG_LEVEL_INFO} ] && echo "${@}" ; } + +function log_debug { [ ${LOG_LEVEL} -ge ${LOG_LEVEL_DEBUG} ] && echo "${@}" ; } + +function log_trace { [ ${LOG_LEVEL} -ge ${LOG_LEVEL_TRACE} ] && echo "${@}" ; }