V8.00.000.2025.06.17

Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
2025-07-29 12:54:50 +02:00
parent e9f3297cd1
commit f4fb74f689
16 changed files with 994 additions and 341 deletions

View File

@@ -15,7 +15,7 @@ guard_sourcing
#######################################
# Log level values for comparison.
# Arguments:
# 1: "${LOG_LEVEL}" one of: "debug" | "info" | "notice" | "warn" | "error" | "critical" | "fatal" | "emergency"
# 1: LOG_LEVEL: "debug" | "info" | "notice" | "warn" | "error" | "critical" | "fatal" | "emergency"
#######################################
log_level_value() {
case "${1,,}" in
@@ -35,7 +35,7 @@ log_level_value() {
# Globals:
# VAR_DEFAULT_LOG_LEVEL
# Arguments:
# 1: "${LOG_LEVEL}" one of: "debug" | "info" | "notice" | "warn" | "error" | "critical" | "fatal" | "emergency"
# 1: LOG_LEVEL: "debug" | "info" | "notice" | "warn" | "error" | "critical" | "fatal" | "emergency"
#######################################
do_should_log() {
# shellcheck disable=SC2155
@@ -56,7 +56,7 @@ do_should_log() {
# WHI
# YEL
# Arguments:
# 1: "${LOG_LEVEL}" one of: "debug" | "info" | "notice" | "warn" | "error" | "critical" | "fatal" | "emergency"
# 1: LOG_LEVEL: "debug" | "info" | "notice" | "warn" | "error" | "critical" | "fatal" | "emergency"
#######################################
do_get_log_color() {
case "${1,,}" in
@@ -75,9 +75,9 @@ do_get_log_color() {
# LOG_ERR
# LOG_INS
# Arguments:
# 1: "${LOG_LEVEL}" one of: "debug" | "info" | "notice" | "warn" | "error" | "critical" | "fatal" | "emergency"
# 2: "${LOG_ONLY}" one of: "file_only" | "tty"
# *: "${*}" arbitrary text string to log.
# 1: LOG_LEVEL: "debug" | "info" | "notice" | "warn" | "error" | "critical" | "fatal" | "emergency"
# 2: LOG_ONLY: "file_only" | "tty"
# *: Arbitrary text string to log.
#######################################
do_log() {
### Reading arguments.
@@ -86,9 +86,22 @@ do_log() {
declare var_msg_string="${*}"
### Declare variables.
declare log_uniform=""
declare var_color; var_color=$(do_get_log_color "${var_log_level}")
declare var_ts; var_ts="$(date -u '+%Y-%m-%dT%H:%M:%S.%4N%z')"
declare var_log_entry=("${var_ts} [${var_log_level}]: ${var_msg_string}")
case "${var_log_level,,}" in
debug) log_uniform="[DEBUG] ";;
info) log_uniform="[INFO] ";;
notice) log_uniform="[NOTICE] ";;
warn) log_uniform="[WARNING] ";;
error) log_uniform="[ERROR] ";;
critical) log_uniform="[CRITICAL] ";;
fatal) log_uniform="[FATAL] ";;
emergency) log_uniform="[EMERGENCY]";;
esac
declare var_log_entry=("${var_ts} ${log_uniform}: ${var_msg_string}")
if do_should_log "${var_log_level}"; then
if [[ "${var_log_only,,}" == "file_only" ]]; then