Skip to content

feat(audit): don't print None values

Dmitry Ivanov requested to merge funbringer/audit-eat-none-values into master

Summary

  • feat(audit): don't print None values

This patch adds a proper support for auxiliary fields containing Option<T>. As of now, KV pairs containing Some(x) will be printed as just x, while the ones with None won't be printed at all.

Example:

crate::audit!(
    message: "demo audit event",
    title: "example",
    severity: Low,
    test: Some(0u32),
);
{
  "id": "1.0.1",
  "message": "demo audit event",
  "severity": "low",
  "time": "2023-12-06T17:16:51.085+0300",
  "title": "example",
  "test": "0"
}
crate::audit!(
    message: "demo audit event",
    title: "example",
    severity: Low,
    test: None::<i32>,
);
{
  "id": "1.0.1",
  "message": "demo audit event",
  "severity": "low",
  "time": "2023-12-06T17:16:51.085+0300",
  "title": "example"
}

Part of #349 (closed)

Ensure that

  • New code is covered by tests
  • API is documented
  • Changelog is up to date
  • (if Lua API changed) Lua API version is bumped in luamod.rs
  • (if necessary) A follow-up doc issue is created in picodata/docs and linked here
Edited by Dmitry Ivanov

Merge request reports