]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: log: add a log level override value in struct session
authorWilly Tarreau <w@1wt.eu>
Tue, 11 Jun 2013 15:18:02 +0000 (17:18 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 11 Jun 2013 15:50:26 +0000 (17:50 +0200)
This log level will be used in a further patch to change the log level
depending on the request or response.

include/types/session.h
src/log.c
src/peers.c
src/proto_http.c

index b6bff5753fd06ac3f54fee8802386558e5322f64..efdcaa6912d832d1c9fb8ddc748542ed29df6ad5 100644 (file)
@@ -151,6 +151,7 @@ struct session {
        struct stream_interface si[2];          /* client and server stream interfaces */
        struct {
                int logwait;                    /* log fields waiting to be collected : LW_* */
+               int level;                      /* log level to force + 1 if > 0, -1 = no log */
                struct timeval accept_date;     /* date of the accept() in user date */
                struct timeval tv_accept;       /* date of the accept() in internal date (monotonic) */
                struct timeval tv_request;      /* date the request arrives, {0,0} if never occurs */
index 627351f357ec40ace529192d70db1e16c85dd9f7..8f8fd8f8c4fb18bbdfeb87f33938b35c97d5993e 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -1528,9 +1528,18 @@ void sess_log(struct session *s)
        if (LIST_ISEMPTY(&s->fe->logsrvs))
                return;
 
-       level = LOG_INFO;
-       if (err && (s->fe->options2 & PR_O2_LOGERRORS))
-               level = LOG_ERR;
+       if (s->logs.level) { /* loglevel was overridden */
+               if (s->logs.level == -1) {
+                       s->logs.logwait = 0; /* logs disabled */
+                       return;
+               }
+               level = s->logs.level - 1;
+       }
+       else {
+               level = LOG_INFO;
+               if (err && (s->fe->options2 & PR_O2_LOGERRORS))
+                       level = LOG_ERR;
+       }
 
        tmplog = update_log_hdr();
        size = tmplog - logline;
index 61fb938a3f050b228f85039c2a05e32c137a305d..998e61daca8cd0dfb12f060d904892ff787aef0f 100644 (file)
@@ -1185,6 +1185,7 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
         */
 
        s->logs.logwait = 0;
+       s->logs.level = 0;
        s->do_log = NULL;
 
        /* default error reporting function, may be changed by analysers */
index ed6c90b0552bbc7e6e65acc28e3cf1cbd6ee9f0d..de9b331300d86a1338ddf293dab979f7a735ee4a 100644 (file)
@@ -2528,6 +2528,7 @@ int http_wait_for_request(struct session *s, struct channel *req, int an_bit)
                msg->msg_state = HTTP_MSG_RQBEFORE;
                req->analysers = 0;
                s->logs.logwait = 0;
+               s->logs.level = 0;
                s->rep->flags &= ~CF_EXPECT_MORE; /* speed up sending a previous response */
                stream_int_retnclose(req->prod, NULL);
                return 0;
@@ -8315,6 +8316,7 @@ void http_reset_txn(struct session *s)
 
        s->be = s->fe;
        s->logs.logwait = s->fe->to_log;
+       s->logs.level = 0;
        session_del_srv_conn(s);
        s->target = NULL;
        /* re-init store persistence */