* Will not log if the frontend has no log defined.
*/
void strm_log(struct stream *s);
-void sess_log(struct session *sess);
+
+/* send an error log for the session, embryonic version should be used
+ * when the log is emitted for a session which is still in embryonic state
+ * (originating from a connection) and requires special handling.
+ */
+void _sess_log(struct session *sess, int embryonic);
+static inline void sess_log(struct session *sess)
+{
+ _sess_log(sess, 0);
+}
+static inline void sess_log_embryonic(struct session *sess)
+{
+ _sess_log(sess, 1);
+}
/* send a applicative log with custom list of loggers */
void app_log(struct list *loggers, struct buffer *tag, int level, const char *format, ...)
* in the frontend. The caller must simply know that it should not call this
* function to report unimportant events. It is safe to call this function with
* sess==NULL (will not do anything).
+ *
+ * if <embryonic> is set, then legacy error log payload will be generated unless
+ * logformat_error is specified (ie: normal logformat is ignored in this case).
+ *
*/
-void sess_log(struct session *sess)
+void _sess_log(struct session *sess, int embryonic)
{
int size, level;
int sd_size = 0;
if (!lf_expr_isempty(&sess->fe->logformat_error))
size = sess_build_logline(sess, NULL, logline, global.max_syslog_len, &sess->fe->logformat_error);
- else
+ else if (!embryonic)
size = sess_build_logline(sess, NULL, logline, global.max_syslog_len, &sess->fe->logformat);
+ else { /* no logformat_error and embryonic==1 */
+ struct buffer buf;
+
+ buf = b_make(logline, global.max_syslog_len, 0, 0);
+ session_embryonic_build_legacy_err(sess, &buf);
+ size = buf.data;
+ }
if (size > 0) {
_HA_ATOMIC_INC(&sess->fe->log_count);
__send_log(&sess->fe->loggers, &sess->fe->log_tag, level,
*/
static void session_kill_embryonic(struct session *sess, unsigned int state)
{
- int level = LOG_INFO;
struct connection *conn = __objt_conn(sess->origin);
struct task *task = sess->task;
unsigned int log = sess->fe->to_log;
- if (sess->fe->options2 & PR_O2_LOGERRORS)
- level = LOG_ERR;
-
if (log && (sess->fe->options & PR_O_NULLNOLOG)) {
/* with "option dontlognull", we don't log connections with no transfer */
if (!conn->err_code ||
conn->err_code = CO_ER_SSL_TIMEOUT;
}
- if(!lf_expr_isempty(&sess->fe->logformat_error)) {
- /* Display a log line following the configured error-log-format. */
- sess_log(sess);
- }
- else {
- session_embryonic_build_legacy_err(sess, &trash);
- send_log(sess->fe, level, "%s", trash.area);
- }
+ sess_log_embryonic(sess);
}
/* kill the connection now */