MEDIUM: log-format: make the format parser more robust and more extensible

The log-format parser reached a limit making it hard to add new features.
It also suffers from a weak handling of certain incorrect corner cases,
for example "%{foo}" is emitted as a litteral while syntactically it's an
argument to no variable. Also the argument parser had to redo some of the
job with some cases causing minor memory leaks (eg: ignored args).

This work aims at improving the situation so that slightly better reporting
is possible and that it becomes possible to extend the log format. The code
has a few more states but looks significantly simpler. The parser is now
capable of reporting ignored arguments and truncated lines.
diff --git a/include/types/log.h b/include/types/log.h
index c81ab0d..0ed79d4 100644
--- a/include/types/log.h
+++ b/include/types/log.h
@@ -97,15 +97,16 @@
 	LOG_FMT_SSL_VERSION,
 };
 
-/* enum for parse_logformat */
+/* enum for parse_logformat_string */
 enum {
-	LF_TEXT = 0,
-	LF_SEPARATOR,
-	LF_VAR, // after %
-
-	LF_STARTVAR,   // %
-	LF_STARG, // { and within { }
-	LF_EDARG, // end arg }
+	LF_INIT = 0,   // before first character
+	LF_TEXT,       // normal text
+	LF_SEPARATOR,  // a single separator
+	LF_VAR,        // variable name, after '%' or '%{..}'
+	LF_STARTVAR,   // % in text
+	LF_STARG,      // after '%{' and berore '}'
+	LF_EDARG,      // '}' after '%{'
+	LF_END,        // \0 found
 };