V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m29s

Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
2025-06-25 19:22:15 +02:00
parent 96fb3c722c
commit 1fc161d4eb
3 changed files with 65 additions and 59 deletions

View File

@@ -17,15 +17,14 @@
#######################################
log_level_value() {
case "${1,,}" in
debug) echo 0 ;;
info) echo 1 ;;
notice) echo 2 ;;
warn) echo 3 ;;
error) echo 4 ;;
critical) echo 5 ;;
fatal) echo 6 ;;
emergency) echo 7 ;;
*) echo 0 ;;
debug) printf '%d' 7 ;;
info) printf '%d' 6 ;;
notice) printf '%d' 5 ;;
warn) printf '%d' 4 ;;
error) printf '%d' 3 ;;
critical) printf '%d' 2 ;;
fatal) printf '%d' 1 ;;
emergency) printf '%d' 0 ;;
esac
}
@@ -38,14 +37,11 @@ log_level_value() {
#######################################
do_should_log() {
# shellcheck disable=SC2155
declare var_desired_log_value=$(log_level_value "$1")
declare -i var_desired_log_value=$(log_level_value "$1") # Desired log level
# shellcheck disable=SC2155
declare var_default_log_value=$(log_level_value "${DEFAULT_LOG_LEVEL}")
if [[ ${var_desired_log_value} -ge ${var_default_log_value} ]]; then
return 0
else
return 1
fi
declare -i var_default_log_value=$(log_level_value "${DEFAULT_LOG_LEVEL}") # Current threshold
### Return true if a message should be logged.
[[ $var_desired_log_value -le $var_default_log_value ]]
}
#######################################
@@ -55,6 +51,7 @@ do_should_log() {
# C_GRN
# C_MAG
# C_RED
# C_WHI
# C_YEL
# Arguments:
# $1: "${LOG_LEVEL}" one of: "debug" | "info" | "notice" | "warn" | "error" | "critical" | "fatal" | "emergency"
@@ -92,12 +89,12 @@ do_log() {
declare var_log_entry=("${var_ts} [${var_log_level}]: ${ary_message[*]}")
if do_should_log "${var_log_level}"; then
if [[ "${var_log_only,,}" == true ]]; then
if [[ "${var_log_only,,}" == "true" ]]; then
case "${var_log_level,,}" in
debug | info | notice) do_print_log "${var_log_entry[*]}" >> "${LOG_INS}" ;;
warn | error | critical | fatal | emergency ) do_print_log "${var_log_entry[*]}" >> "${LOG_ERR}" ;;
esac
elif [[ ${var_log_only,,} == false ]]; then
elif [[ "${var_log_only,,}" == "false" ]]; then
case "${var_log_level,,}" in
debug | info | notice)
if [[ ${#var_msg_string} -le 76 ]]; then