mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-06-20 16:15:58 +02:00
chore: Avoid logging a warning when LOG_LEVEL
is unset (#4497)
This commit is contained in:
parent
ea03808c8f
commit
8fa6e6deba
1 changed files with 6 additions and 16 deletions
|
@ -4,7 +4,7 @@
|
|||
declare -A VARS
|
||||
|
||||
function _early_variables_setup() {
|
||||
__environment_variables_log_level
|
||||
__ensure_valid_log_level
|
||||
__environment_variables_from_files
|
||||
_obtain_hostname_and_domainname
|
||||
__environment_variables_backwards_compatibility
|
||||
|
@ -181,21 +181,11 @@ function __environment_variables_general_setup() {
|
|||
fi
|
||||
}
|
||||
|
||||
function __environment_variables_log_level() {
|
||||
if [[ ${LOG_LEVEL} == 'trace' ]] \
|
||||
|| [[ ${LOG_LEVEL} == 'debug' ]] \
|
||||
|| [[ ${LOG_LEVEL} == 'info' ]] \
|
||||
|| [[ ${LOG_LEVEL} == 'warn' ]] \
|
||||
|| [[ ${LOG_LEVEL} == 'error' ]]
|
||||
then
|
||||
return 0
|
||||
else
|
||||
local DEFAULT_LOG_LEVEL='info'
|
||||
_log 'warn' "Log level '${LOG_LEVEL}' is invalid (falling back to default '${DEFAULT_LOG_LEVEL}')"
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
VARS[LOG_LEVEL]="${DEFAULT_LOG_LEVEL}"
|
||||
LOG_LEVEL="${DEFAULT_LOG_LEVEL}"
|
||||
# `LOG_LEVEL` must be set early to correctly filter calls to `scripts/helpers/log.sh:_log()`
|
||||
function __ensure_valid_log_level() {
|
||||
if [[ ! ${LOG_LEVEL:-info} =~ ^(trace|debug|info|warn|error)$ ]]; then
|
||||
_log 'warn' "Log level '${LOG_LEVEL}' is invalid (falling back to default: 'info')"
|
||||
LOG_LEVEL='info'
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue