]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: log: move the log code to sess_build_logline() to add extra arguments
authorWilly Tarreau <w@1wt.eu>
Wed, 5 Sep 2018 12:58:15 +0000 (14:58 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 5 Sep 2018 18:01:23 +0000 (20:01 +0200)
The current build_logline() can only be used with valid streams, which
means it is not suitable for use from muxes. We start by moving it into
another more generic function which takes the session as an argument,
to avoid complexifying all the internal API for jsut a few use cases.
This new function is not supposed to be called directly from outside so
we'll be able to instrument it to support several calling conventions.

For now the behaviour and conditions remain unchanged.

include/proto/log.h
src/log.c

index 05a7acc555e473690e9a1e98eab3a3ebfdf4f81d..3e17733cec3070cb836a85fd10bf84a03b0544bc 100644 (file)
@@ -34,6 +34,8 @@
 #include <types/proxy.h>
 #include <types/stream.h>
 
+#include <proto/stream.h>
+
 extern struct pool_head *pool_head_requri;
 extern struct pool_head *pool_head_uniqueid;
 
@@ -63,7 +65,13 @@ void deinit_log_buffers();
 /*
  * Builds a log line.
  */
-int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list_format);
+int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t maxsize, struct list *list_format);
+
+static inline int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list_format)
+{
+       return sess_build_logline(strm_sess(s), s, dst, maxsize, list_format);
+}
+
 
 /*
  * send a log for the stream when we have enough info about it.
index dcb2ba0697000f3c3681b569ddf2ad8b895d0d78..4e7818da06078a64b508cb3d20df407750578dce 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -1566,11 +1566,10 @@ void deinit_log_buffers()
 /* Builds a log line in <dst> based on <list_format>, and stops before reaching
  * <maxsize> characters. Returns the size of the output string in characters,
  * not counting the trailing zero which is always added if the resulting size
- * is not zero.
+ * is not zero. It requires a session and a stream.
  */
-int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list_format)
+int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t maxsize, struct list *list_format)
 {
-       struct session *sess = strm_sess(s);
        struct proxy *fe = sess->fe;
        struct proxy *be = s->be;
        struct http_txn *txn = s->txn;