]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: log: add +cbor encoding option
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 23 Apr 2024 08:12:46 +0000 (10:12 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Fri, 26 Apr 2024 16:39:32 +0000 (18:39 +0200)
commitc614fd3b9fe7ce44e6b0f701108577f8cd8f2d90
treef82faf47bd22b0b8e68085cc7dfde5c079904019
parent810303e3e64b3ff9af1de8b8876f0f3cded88837
MINOR: log: add +cbor encoding option

In this patch, we make use of the CBOR (RFC8949) encode helper functions
from the previous commit to implement '+cbor' encoding option for log-
formats. The logic behind it is pretty similar to '+json' encoding option,
except that the produced output is a CBOR payload written in HEX format so
that it remains compatible to use this with regular syslog endpoints.

Example:
  log-format "%{+cbor}o %[int(4)] test %(named_field)[str(ok)]"

Will produce:
  BF6B6E616D65645F6669656C64626F6BFF

  Detailed view (from cbor.me):
    BF                           # map(*)
       6B                        # text(11)
          6E616D65645F6669656C64 # "named_field"
       62                        # text(2)
          6F6B                   # "ok"
       FF                        # primitive(*)

If the option isn't set globally, but on a specific node instead, then
only the value will be encoded according to CBOR specification.

Example:
  log-format "test cbor bool: %{+cbor}[bool(true)]"

Will produce:
  test cbor bool: F5
doc/configuration.txt
include/haproxy/log-t.h
src/log.c