mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-02 00:54:54 +02:00
scripts: new log (#2493)
* added new `_log` function With `_log`, the `_notify` method wa rendered obsolete. `_notify` was not completely removed due to test failures in `check-for-changes.sh`. The new `_log` function properly uses log levels such as `trace`, `debug`, `info`, `warn` and `error`. It provides a cleaner solution and renders `DMS_DEBUG` obsolete too (as only `_notify` depends on it). * converted all helper script to new `_log` function * converted all startup stacks to new `log` function * `start-mailserver.sh` now uses new `_log` function * final test and misc small script adjustments * updated documentation
This commit is contained in:
parent
d8d4b6a189
commit
24031ae365
19 changed files with 367 additions and 221 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
function check
|
||||
{
|
||||
_notify 'tasklog' 'Checking configuration'
|
||||
_log 'info' 'Checking configuration'
|
||||
for FUNC in "${FUNCS_CHECK[@]}"
|
||||
do
|
||||
${FUNC}
|
||||
|
@ -11,10 +11,10 @@ function check
|
|||
|
||||
function _check_hostname
|
||||
{
|
||||
_notify 'task' 'Checking that hostname/domainname is provided or overridden'
|
||||
_log 'debug' 'Checking that hostname/domainname is provided or overridden'
|
||||
|
||||
_notify 'inf' "Domain has been set to ${DOMAINNAME}"
|
||||
_notify 'inf' "Hostname has been set to ${HOSTNAME}"
|
||||
_log 'debug' "Domain has been set to ${DOMAINNAME}"
|
||||
_log 'debug' "Hostname has been set to ${HOSTNAME}"
|
||||
|
||||
# HOSTNAME should be an FQDN (eg: hostname.domain)
|
||||
if ! grep -q -E '^(\S+[.]\S+)$' <<< "${HOSTNAME}"
|
||||
|
@ -22,3 +22,23 @@ function _check_hostname
|
|||
_shutdown 'Setting hostname/domainname is required'
|
||||
fi
|
||||
}
|
||||
|
||||
function _check_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'
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
VARS[LOG_LEVEL]="${DEFAULT_LOG_LEVEL}"
|
||||
LOG_LEVEL="${DEFAULT_LOG_LEVEL}"
|
||||
|
||||
_log 'warn' "Log level '${LOG_LEVEL}' is invalid (falling back to default '${DEFAULT_LOG_LEVEL}')"
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue