MEDIUM: log: add the ability to include samples in logs

Using %[expression] it becomes possible to make the log engine fetch
some samples from the request or the response and provide them in the
logs. Note that this feature is still limited, it does not yet allow
to apply converters, to limit the output length, nor to specify the
direction which should be fetched when a fetch function works in both
directions.

However it's quite convenient to log SSL information or to include some
information that are used in stick tables.

It is worth noting that this has been done in the generic log format
handler, which means that the same information may be used to build the
unique-id header and to pass the information to a backend server.
diff --git a/include/types/log.h b/include/types/log.h
index 0ed79d4..2a3a147 100644
--- a/include/types/log.h
+++ b/include/types/log.h
@@ -39,7 +39,7 @@
 enum {
 
 	LOG_FMT_TEXT = 0, /* raw text */
-
+	LOG_FMT_EXPR,     /* sample expression */
 	LOG_FMT_SEPARATOR, /* separator replaced by one space */
 	LOG_FMT_VARIABLE,
 
@@ -106,21 +106,25 @@
 	LF_STARTVAR,   // % in text
 	LF_STARG,      // after '%{' and berore '}'
 	LF_EDARG,      // '}' after '%{'
+	LF_STEXPR,     // after '%[' or '%{..}[' and berore ']'
+	LF_EDEXPR,     // ']' after '%['
 	LF_END,        // \0 found
 };
 
 
 struct logformat_node {
 	struct list list;
-	int type;
-	int options;
-	char *arg;
+	int type;      // LOG_FMT_*
+	int options;   // LOG_OPT_*
+	char *arg;     // text for LOG_FMT_TEXT, arg for others
+	void *expr;    // for use with LOG_FMT_EXPR
 };
 
 #define LOG_OPT_HEXA		0x00000001
 #define LOG_OPT_MANDATORY	0x00000002
 #define LOG_OPT_QUOTE		0x00000004
-
+#define LOG_OPT_REQ_CAP         0x00000008
+#define LOG_OPT_RES_CAP         0x00000010
 
 
 /* fields that need to be logged. They appear as flags in session->logs.logwait */