MINOR: log: explicitly handle extra log origins as error when relevant

Thanks to previous commit, we can know check for log_orig optional flags
in functions taking struct log_orig as parameter. Let's take this
opportunity to add the LOG_ORIG_FL_ERROR flag and check this flag at a
few places to handle the log message differently because if the flag is
set then the caller expects the log to be handled as an error explicitly.

e.g.: in _process_send_log_override(), if the flag is set, use the error
log format instead of the dedicated one.
This commit is contained in:
Aurelien DARRAGON
2024-07-31 14:10:52 +02:00
parent 3c15ee05e9
commit f8bb9d5c57
2 changed files with 11 additions and 1 deletions

View File

@@ -280,6 +280,7 @@ enum log_orig_id {
/* log orig flags
*/
#define LOG_ORIG_FL_NONE 0x0000
#define LOG_ORIG_FL_ERROR 0x0001
#define LOG_ORIG_FL_ALL 0xFFFF
struct log_orig {

View File

@@ -2896,6 +2896,7 @@ static inline void _process_send_log_override(struct process_send_log_ctx *ctx,
struct ist orig_tag = hdr.metadata[LOG_META_TAG];
struct ist orig_sd = hdr.metadata[LOG_META_STDATA];
enum log_orig_id orig = (ctx) ? ctx->origin.id : LOG_ORIG_UNSPEC;
uint16_t orig_fl = (ctx) ? ctx->origin.flags : LOG_ORIG_FL_NONE;
BUG_ON(!prof);
@@ -2936,6 +2937,13 @@ static inline void _process_send_log_override(struct process_send_log_ctx *ctx,
struct log_profile_step_extra *extra;
/* catchall for extra log origins */
if ((orig_fl & LOG_ORIG_FL_ERROR) && prof->error) {
/* extra orig with explicit error flag, must be
* handled as an error
*/
step = prof->error;
break;
}
/* check if there is a log step defined for this log origin */
extra = container_of_safe(eb32_lookup(&prof->extra, orig),
@@ -5150,7 +5158,8 @@ void strm_log(struct stream *s, struct log_orig origin)
err = (s->flags & SF_REDISP) ||
((s->flags & SF_ERR_MASK) > SF_ERR_LOCAL) ||
(((s->flags & SF_ERR_MASK) == SF_ERR_NONE) && s->conn_retries) ||
((sess->fe->mode == PR_MODE_HTTP) && s->txn && s->txn->status >= 500);
((sess->fe->mode == PR_MODE_HTTP) && s->txn && s->txn->status >= 500) ||
(origin.flags & LOG_ORIG_FL_ERROR);
if (!err && (sess->fe->options2 & PR_O2_NOLOGNORM))
return;