diff --git a/doc/configuration.txt b/doc/configuration.txt index 0a111eb0c..afcf4488b 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -25759,6 +25759,10 @@ Flags are : syslog endpoints. As with json encoding, incomplete numerical values will be encoded as-is and '+E' option will be ignored. + When combined with '+bin' option, it will directly generate raw + binary CBOR payload. Be careful, because it will obviously generate + non-printable chars, thus it is mainly intented for use with + set-var-fmt, rings and binary-capable log endpoints. Example: diff --git a/src/log.c b/src/log.c index 6354f63a8..2e8e1b281 100644 --- a/src/log.c +++ b/src/log.c @@ -1774,8 +1774,15 @@ static char *_encode_byte_hex(char *start, char *stop, unsigned char byte) static char *_lf_cbor_encode_byte(struct cbor_encode_ctx *cbor_ctx, char *start, char *stop, unsigned char byte) { - __maybe_unused struct lf_buildctx *ctx = cbor_ctx->e_byte_fct_ctx; + struct lf_buildctx *ctx = cbor_ctx->e_byte_fct_ctx; + if (ctx->options & LOG_OPT_BIN) { + /* raw output */ + if ((stop - start) < 1) + return NULL; + *start++ = byte; + return start; + } return _encode_byte_hex(start, stop, byte); }