[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.
diff --git a/include/types/session.h b/include/types/session.h
index a92949b..92bfa06 100644
--- a/include/types/session.h
+++ b/include/types/session.h
@@ -188,6 +188,7 @@
 		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 {
diff --git a/src/client.c b/src/client.c
index 78387a1..8e8dc53 100644
--- a/src/client.c
+++ b/src/client.c
@@ -206,6 +206,11 @@
 		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 @@
 				/* 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];
diff --git a/src/proto_http.c b/src/proto_http.c
index 7bc9fa6..b14322e 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -1858,7 +1858,7 @@
 			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 @@
 				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 @@
 		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;
 		}
 
diff --git a/src/session.c b/src/session.c
index 75cc3f3..1eb7b69 100644
--- a/src/session.c
+++ b/src/session.c
@@ -321,7 +321,7 @@
 		 * 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 @@
 	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 */