diff --git a/docs/networking/proxies/haproxy.md b/docs/networking/proxies/haproxy.md index 497df7c6c..9b7dfbc01 100644 --- a/docs/networking/proxies/haproxy.md +++ b/docs/networking/proxies/haproxy.md @@ -101,6 +101,16 @@ dokku haproxy:logs --tail --num 10 The above command will show logs continually from the vector container, with an initial history of 10 log lines +### Changing the Haproxy log level + +Haproxy log output is set to `ERROR` by default. It may be changed by setting the `log-level` property with the `--global` flag: + +```shell +dokku haproxy:set --global log-level DEBUG +``` + +After modifying, the Haproxy container will need to be restarted. + ## Displaying Haproxy reports for an app You can get a report about the app's Haproxy config using the `haproxy:report` command: diff --git a/plugins/haproxy-vhosts/command-functions b/plugins/haproxy-vhosts/command-functions index 283416120..05aceb4b5 100755 --- a/plugins/haproxy-vhosts/command-functions +++ b/plugins/haproxy-vhosts/command-functions @@ -36,6 +36,7 @@ cmd-haproxy-report-single() { verify_app_name "$APP" local flag_map=( "--haproxy-image: $(fn-haproxy-image)" + "--haproxy-log-level: $(fn-haproxy-log-level)" ) if [[ -z "$INFO_FLAG" ]]; then diff --git a/plugins/haproxy-vhosts/internal-functions b/plugins/haproxy-vhosts/internal-functions index 34d44f534..28aecf6a1 100755 --- a/plugins/haproxy-vhosts/internal-functions +++ b/plugins/haproxy-vhosts/internal-functions @@ -35,7 +35,8 @@ fn-haproxy-template-compose-file() { COMPOSE_TEMPLATE="$CUSTOM_COMPOSE_TEMPLATE" fi - local SIGIL_PARAMS=(HAPROXY_IMAGE="$(fn-haproxy-image)") + local SIGIL_PARAMS=(HAPROXY_IMAGE="$(fn-haproxy-image)" + HAPROXY_LOG_LEVEL="$(fn-traefik-log-level)") sigil -f "$COMPOSE_TEMPLATE" "${SIGIL_PARAMS[@]}" | cat -s >"$OUTPUT_PATH" } @@ -43,3 +44,9 @@ fn-haproxy-template-compose-file() { fn-haproxy-image() { fn-plugin-property-get-default "haproxy" "--global" "image" "byjg/easy-haproxy:4.2.0" } + +fn-haproxy-log-level() { + local log_level + log_level="$(fn-plugin-property-get-default "haproxy" "--global" "log-level" "ERROR")" + echo "${log_level^^}" +} diff --git a/plugins/haproxy-vhosts/subcommands/set b/plugins/haproxy-vhosts/subcommands/set index 54f7388dc..d893c6c6e 100755 --- a/plugins/haproxy-vhosts/subcommands/set +++ b/plugins/haproxy-vhosts/subcommands/set @@ -9,13 +9,13 @@ cmd-haproxy-set() { declare cmd="haproxy:set" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" KEY="$2" VALUE="$3" - local VALID_KEYS=("image") - local GLOBAL_KEYS=("image") + local VALID_KEYS=("image" "log-level") + local GLOBAL_KEYS=("image" "log-level") [[ -z "$KEY" ]] && dokku_log_fail "No key specified" if ! fn-in-array "$KEY" "${VALID_KEYS[@]}"; then - dokku_log_fail "Invalid key specified, valid keys include: image" + dokku_log_fail "Invalid key specified, valid keys include: image log-level" fi if ! fn-in-array "$KEY" "${GLOBAL_KEYS[@]}"; then diff --git a/plugins/haproxy-vhosts/templates/compose.yml.sigil b/plugins/haproxy-vhosts/templates/compose.yml.sigil index 816c8efde..49e714123 100644 --- a/plugins/haproxy-vhosts/templates/compose.yml.sigil +++ b/plugins/haproxy-vhosts/templates/compose.yml.sigil @@ -8,6 +8,7 @@ services: environment: - EASYHAPROXY_DISCOVER=docker - EASYHAPROXY_LABEL_PREFIX=haproxy + - EASYHAPROXY_LOG_LEVEL={{ $.HAPROXY_LOG_LEVEL }} network_mode: bridge