diff --git a/target/scripts/helpers/log.sh b/target/scripts/helpers/log.sh index 190fad5c..4af09c04 100644 --- a/target/scripts/helpers/log.sh +++ b/target/scripts/helpers/log.sh @@ -39,15 +39,23 @@ function _log return 1 fi - local MESSAGE LEVEL_AS_INT + local MESSAGE LEVEL_AS_INT LOG_LEVEL_FALLBACK MESSAGE="${LOG_RESET}[" - case "${LOG_LEVEL:-}" in - ( 'trace' ) LEVEL_AS_INT=5 ;; - ( 'debug' ) LEVEL_AS_INT=4 ;; - ( 'warn' ) LEVEL_AS_INT=2 ;; - ( 'error' ) LEVEL_AS_INT=1 ;; - ( * ) LEVEL_AS_INT=3 ;; + if [[ -e /etc/dms-settings ]] + then + LOG_LEVEL_FALLBACK=$(grep "^LOG_LEVEL=" /etc/dms-settings | cut -d '=' -f 2) + LOG_LEVEL_FALLBACK="${LOG_LEVEL_FALLBACK:1:-1}" + else + LOG_LEVEL_FALLBACK='info' + fi + + case "${LOG_LEVEL:-${LOG_LEVEL_FALLBACK}}" in + ( 'trace' ) LEVEL_AS_INT=5 ;; + ( 'debug' ) LEVEL_AS_INT=4 ;; + ( 'warn' ) LEVEL_AS_INT=2 ;; + ( 'error' ) LEVEL_AS_INT=1 ;; + ( * ) LEVEL_AS_INT=3 ;; esac case "${1}" in diff --git a/target/scripts/helpers/utils.sh b/target/scripts/helpers/utils.sh index f7e51eb8..f217b8d8 100644 --- a/target/scripts/helpers/utils.sh +++ b/target/scripts/helpers/utils.sh @@ -11,3 +11,12 @@ function _is_comment { grep -q -E "^\s*$|^\s*#" <<< "${1}" } + +# Provide the name of an environment variable to this function +# and it will return its value stored in /etc/dms-settings +function _get_dms_env_value +{ + local VALUE + VALUE=$(grep "^${1}=" /etc/dms-settings | cut -d '=' -f 2) + printf '%s' "${VALUE:1:-1}" +}