[MINOR] call session->do_log() for logging
In order to avoid having to call per-protocol logging function directly from session.c, it's better to assign the logging function when the session is created. This also eliminates a test when the function is needed, and opens the way to more complete logging functions.
This commit is contained in:
parent
55a8d0e1bb
commit
a5555ec68a
|
@ -188,6 +188,7 @@ struct session {
|
|||
long long bytes_in; /* number of bytes transferred from the client to the server */
|
||||
long long bytes_out; /* number of bytes transferred from the server to the client */
|
||||
} logs;
|
||||
void (*do_log)(struct session *s); /* the function to call in order to log */
|
||||
short int data_source; /* where to get the data we generate ourselves */
|
||||
short int data_state; /* where to get the data we generate ourselves */
|
||||
union {
|
||||
|
|
|
@ -206,6 +206,11 @@ int event_accept(int fd) {
|
|||
else
|
||||
s->logs.logwait = p->to_log;
|
||||
|
||||
if (s->logs.logwait & LW_REQ)
|
||||
s->do_log = http_sess_log;
|
||||
else
|
||||
s->do_log = tcp_sess_log;
|
||||
|
||||
s->logs.accept_date = date; /* user-visible date for logging */
|
||||
s->logs.tv_accept = now; /* corrected date for internal use */
|
||||
tv_zero(&s->logs.tv_request);
|
||||
|
@ -276,7 +281,7 @@ int event_accept(int fd) {
|
|||
/* we have the client ip */
|
||||
if (s->logs.logwait & LW_CLIP)
|
||||
if (!(s->logs.logwait &= ~LW_CLIP))
|
||||
tcp_sess_log(s);
|
||||
s->do_log(s);
|
||||
}
|
||||
else if (s->cli_addr.ss_family == AF_INET) {
|
||||
char pn[INET_ADDRSTRLEN], sn[INET_ADDRSTRLEN];
|
||||
|
|
|
@ -1858,7 +1858,7 @@ int process_request(struct session *t)
|
|||
client_retnclose(t, &http_200_chunk);
|
||||
goto return_prx_cond;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 3: Maybe we have to copy the original REQURI for the logs ?
|
||||
* Note: we cannot log anymore if the request has been
|
||||
|
@ -1875,7 +1875,7 @@ int process_request(struct session *t)
|
|||
txn->uri[urilen] = 0;
|
||||
|
||||
if (!(t->logs.logwait &= ~LW_REQ))
|
||||
http_sess_log(t);
|
||||
t->do_log(t);
|
||||
} else {
|
||||
Alert("HTTP logging : out of memory.\n");
|
||||
}
|
||||
|
@ -3058,10 +3058,7 @@ int process_response(struct session *t)
|
|||
if (t->fe->to_log && !(t->logs.logwait & LW_BYTES)) {
|
||||
t->logs.t_close = t->logs.t_data; /* to get a valid end date */
|
||||
t->logs.bytes_out = txn->rsp.eoh;
|
||||
if (t->fe->to_log & LW_REQ)
|
||||
http_sess_log(t);
|
||||
else
|
||||
tcp_sess_log(t);
|
||||
t->do_log(t);
|
||||
t->logs.bytes_out = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -321,7 +321,7 @@ void sess_establish(struct session *s, struct stream_interface *si)
|
|||
* bytes from the server, then this is the right moment. */
|
||||
if (s->fe->to_log && !(s->logs.logwait & LW_BYTES)) {
|
||||
s->logs.t_close = s->logs.t_connect; /* to get a valid end date */
|
||||
tcp_sess_log(s);
|
||||
s->do_log(s);
|
||||
}
|
||||
#ifdef CONFIG_HAP_TCPSPLICE
|
||||
if ((s->fe->options & s->be->options) & PR_O_TCPSPLICE) {
|
||||
|
@ -965,10 +965,7 @@ void process_session(struct task *t, int *next)
|
|||
if (s->logs.logwait &&
|
||||
!(s->flags & SN_MONITOR) &&
|
||||
(!(s->fe->options & PR_O_NULLNOLOG) || s->req->total)) {
|
||||
if (s->fe->to_log & LW_REQ)
|
||||
http_sess_log(s);
|
||||
else
|
||||
tcp_sess_log(s);
|
||||
s->do_log(s);
|
||||
}
|
||||
|
||||
/* the task MUST not be in the run queue anymore */
|
||||
|
|
Loading…
Reference in New Issue