Json.md
PuduLangLog.Formatting.Json
type: module path: "@root/src/PuduLangLog/Formatting/Json.pudu" fidelity: Active grammar: "[[grammar/pudu]]" depth_score: 0.6 depth_status: MEDIUM tags: [module, formatter] aliases: [PuduLangLog.Formatting.Json]
Purpose
A [[domain/Formatting|formatter]] writing each event as one JSON document with named members, for destinations that read events back as documents.
Interface
Signatures
export type Options = { renderMessage: Bool, closingDelimiter: Str }
export fn defaults() -> Options
export fn formatter(options: Options) -> Log.FormatterLinkage
- Requires: [[src/PuduLangLog]], [[src/PuduLangLog/Domain/Dates]], [[src/PuduLangLog/Domain/Display]], [[src/PuduLangLog/Domain/Json]], [[src/PuduLangLog/Domain/Levels]],
Std.Option. - Consumed by: package users and settings.
Algorithm
- Members in order:
Timestamp(round trip),Level(full name),MessageTemplate,RenderedMessagewhen asked for,TraceId,SpanId,Exception,Propertieswhen there are any, andRenderingswhen a hole has a format. Renderingsgroups formatted holes by property name in order of first appearance; each entry is{"Format": …, "Rendering": …}, rendered with text values unquoted.- Structures in properties carry their tag as
_typeTag; every document ends with the closing delimiter, a line break by default.
Negative Logic (Prohibited Paths)
- No member is written empty: absent parts are left out.
Edge Cases
- A template repeating one property with two formats lists both renderings under that name.
Depth
DEPTH 0.6 (MEDIUM). Tested by test/PuduLangLog/Formatting/FormattingTest.
Grill Log
- Q: Why keep renderings when properties already hold the values? A: A reader that rebuilds the message needs the formatted text the program saw, which the raw value alone does not give. _Rejected:_ values only.
Referenced by
[[src/PuduLangLog/_MOC]] · [[src/PuduLangLog/Settings/Registry]] · [[subsystems/Formatting]]
