mirror of
http://git.haproxy.org/git/haproxy.git
synced 2026-02-08 11:13:31 +02:00
MINOR: log: add +json encoding option
In this patch, we add the "+json" log format option that can be set
globally or per log format node.
What it does, it that it sets the LOG_OPT_ENCODE_JSON flag for the
current context which is provided to all lf_* log building function.
This way, all lf_* are now aware of this option and try to comply with
JSON specification when the option is set.
If the option is set globally, then sess_build_logline() will produce a
map-like object with key=val pairs for named logformat nodes.
(logformat nodes that don't have a name are simply ignored).
Example:
log-format "%{+json}o %[int(4)] test %(named_field)[str(ok)]"
Will produce:
{"named_field": "ok"}
If the option isn't set globally, but on a specific node instead, then
only the value will be encoded according to JSON specification.
Example:
log-format "{ \"manual_key\": %(named_field){+json}[bool(true)] }"
Will produce:
{"manual_key": true}
When the option is set, +E option will be ignored, and partial numerical
values (ie: because of logasap) will be encoded as-is.
This commit is contained in:
@@ -48,6 +48,10 @@
|
||||
#define LOG_OPT_ESC 0x00000040
|
||||
#define LOG_OPT_MERGE_SPACES 0x00000080
|
||||
#define LOG_OPT_BIN 0x00000100
|
||||
/* unused: 0x00000200 ... 0x00000800 */
|
||||
#define LOG_OPT_ENCODE_JSON 0x00001000
|
||||
/* unused encode: 0x00002000 */
|
||||
#define LOG_OPT_ENCODE 0x00003000
|
||||
|
||||
|
||||
/* Fields that need to be extracted from the incoming connection or request for
|
||||
|
||||
Reference in New Issue
Block a user