diff --git a/src/errors.c b/src/errors.c index 5913cb1d5..bd157a82e 100644 --- a/src/errors.c +++ b/src/errors.c @@ -420,6 +420,22 @@ static void print_message_args(int use_usermsgs_ctx, const char *label, const ch va_end(argp); } +/* + * Display a notice with the happroxy version and executable path when the + * first message is emitted in starting mode. + */ +static void warn_exec_path() +{ + if (!(warned & WARN_EXEC_PATH) && (global.mode & MODE_STARTING)) { + const char *path = get_exec_path(); + + warned |= WARN_EXEC_PATH; + print_message_args(0, "NOTICE", "haproxy version is %s\n", haproxy_version); + if (path) + print_message_args(0, "NOTICE", "path to executable is %s\n", path); + } +} + /* * Displays the message on stderr with the pid. Overrides the quiet * mode during startup. @@ -430,14 +446,7 @@ void ha_alert(const char *fmt, ...) if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE) || !(global.mode & MODE_STARTING)) { - if (!(warned & WARN_EXEC_PATH) && (global.mode & MODE_STARTING)) { - const char *path = get_exec_path(); - - warned |= WARN_EXEC_PATH; - print_message_args(0, "NOTICE", "haproxy version is %s\n", haproxy_version); - if (path) - print_message_args(0, "NOTICE", "path to executable is %s\n", path); - } + warn_exec_path(); va_start(argp, fmt); print_message(1, "ALERT", fmt, argp); va_end(argp); @@ -456,14 +465,7 @@ void ha_warning(const char *fmt, ...) if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE) || !(global.mode & MODE_STARTING)) { - if (!(warned & WARN_EXEC_PATH) && (global.mode & MODE_STARTING)) { - const char *path = get_exec_path(); - - warned |= WARN_EXEC_PATH; - print_message_args(0, "NOTICE", "haproxy version is %s\n", haproxy_version); - if (path) - print_message_args(0, "NOTICE", "path to executable is %s\n", path); - } + warn_exec_path(); va_start(argp, fmt); print_message(1, "WARNING", fmt, argp); va_end(argp);