MEDIUM: log: split of log_format generation

* logformat functions now take a format linked list as argument
* build_logline() build a logline using a format linked list
* rename LOG_* by LOG_FMT_* in enum
* improve error management in build_logline()
diff --git a/include/proto/log.h b/include/proto/log.h
index 0ee60a0..2efb539 100644
--- a/include/proto/log.h
+++ b/include/proto/log.h
@@ -40,6 +40,8 @@
 extern char clf_http_log_format[];
 
 
+int build_logline(struct session *s, char *dst, size_t maxsize, struct list *list_format);
+
 /*
  * send a log for the session when we have enough info about it.
  * Will not log if the frontend has no log defined.
@@ -55,20 +57,19 @@
  * Parse a variable '%varname' or '%{args}varname' in logformat
  *
  */
-int parse_logformat_var(char *str, size_t len, struct proxy *curproxy, int *options);
+int parse_logformat_var(char *str, size_t len, struct proxy *curproxy, struct list *list_format, int *defoptions);
 
 /*
  * add to the logformat linked list
  */
-void add_to_logformat_list(char *start, char *end, int type, struct proxy *curproxy);
+void add_to_logformat_list(char *start, char *end, int type, struct list *list_format);
 
 /*
  * Parse the log_format string and fill a linked list.
  * Variable name are preceded by % and composed by characters [a-zA-Z0-9]* : %varname
  * You can set arguments using { } : %{many arguments}varname
  */
-void parse_logformat_string(char *str, struct proxy *curproxy);
-
+void parse_logformat_string(char *str, struct proxy *curproxy, struct list *list_format, int capabilities);
 /*
  * Displays the message on stderr with the date and pid. Overrides the quiet
  * mode during startup.
diff --git a/include/types/log.h b/include/types/log.h
index 741fba9..efb1d91 100644
--- a/include/types/log.h
+++ b/include/types/log.h
@@ -35,49 +35,49 @@
 /* lists of fields that can be logged */
 enum {
 
-	LOG_TEXT = 0, /* raw text */
+	LOG_FMT_TEXT = 0, /* raw text */
 
-	LOG_SEPARATOR, /* separator replaced by one space */
-	LOG_VARIABLE,
+	LOG_FMT_SEPARATOR, /* separator replaced by one space */
+	LOG_FMT_VARIABLE,
 
 	/* information fields */
-	LOG_GLOBAL,
-	LOG_CLIENTIP,
-	LOG_CLIENTPORT,
-	LOG_SOURCEPORT,
-	LOG_SOURCEIP,
-	LOG_DATE,
-	LOG_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