MEDIUM: connection: Add option to disable legacy error log
In case of connection failure, a dedicated error message is output,
following the format described in section "Error log format" of the
documentation. These messages cannot be configured through a log-format
option.
This patch adds a new option, "dontloglegacyconnerr", that disables
those error logs when set, and "replaces" them by a regular log line
that follows the configured log-format (thanks to a call to sess_log in
session_kill_embryonic).
The new fc_conn_err sample fetch allows to add the legacy error log
information into a regular log format.
This new option is unset by default so the logging logic will remain the
same until this new option is used.
diff --git a/src/session.c b/src/session.c
index 4789ca9..8b83063 100644
--- a/src/session.c
+++ b/src/session.c
@@ -357,14 +357,20 @@
conn->err_code = CO_ER_SSL_TIMEOUT;
}
- session_prepare_log_prefix(sess);
- err_msg = conn_err_code_str(conn);
- if (err_msg)
- send_log(sess->fe, level, "%s: %s\n", trash.area,
- err_msg);
- else
- send_log(sess->fe, level, "%s: unknown connection error (code=%d flags=%08x)\n",
- trash.area, conn->err_code, conn->flags);
+ if (sess->fe->options & PR_O_NOLGCYCONNERR) {
+ /* Display a log line following the configured log-format. */
+ sess_log(sess);
+ }
+ else {
+ session_prepare_log_prefix(sess);
+ err_msg = conn_err_code_str(conn);
+ if (err_msg)
+ send_log(sess->fe, level, "%s: %s\n", trash.area,
+ err_msg);
+ else
+ send_log(sess->fe, level, "%s: unknown connection error (code=%d flags=%08x)\n",
+ trash.area, conn->err_code, conn->flags);
+ }
}
/* kill the connection now */