Skip to content

std:logging/JsonFormatter

Canonical occurrence: protos/lib/logging/JsonFormatter.protos · Protos revision: e99b712ecf658a527b1fe82c8beba2c1286d8dc9.

Deterministic JSON rendering of std:logging/LogEvent values over std:json. Each event renders as one compact JSON object with no line terminator, source metadata, color, or terminal control sequence:

{["timestamp":INTEGER,]"level":LEVEL,"message":STRING,"fields":OBJECT[,"error":true]}

For example {"level":"ERROR","message":"failed","fields":{"requestId":"r-7"},"error":true}. The members always appear in that order. "timestamp" appears exactly when the event has a timestamp and is the exact signed Integer count of nanoseconds of that std:datetime/Instant from 1970-01-01T00:00:00Z, without range limits; an event without a timestamp has no such member. fields is always present, {} when the event has no fields, and holds every field nested inside it, so a field may use any name, including timestamp, level, message, fields, or error. "error":true appears exactly when an Error is attached; the attached Error is never inspected, so every Error renders the same marker.

Structured data maps to JSON nodes of std:json, which alone owns string escaping and number spelling: null, Booleans, and Strings map to the same JSON values; Arrays keep their order; Maps become objects whose members are in ascending order of their names’ Unicode scalar sequences at every depth (the first differing scalar decides, and a proper prefix comes first). An Integer is the exact JSON number of the same value, without range limits. A finite non-zero Float is the decimal with the fewest significant digits that round-trips to the same binary64 value, the same decimal std:logging/TextFormatter renders. Both 0.0 and -0.0 render as the number 0, so JSON output does not preserve the sign of a zero. NaN, Infinity, and -Infinity have no JSON form and signal an Error.

This page lists the complete mechanically observable top-level slot inventory required by D067. Authored documentation, when present, is canonical D062 prose; mechanical presence alone does not create a stability or compatibility promise.

Answers the compact JSON text of event, which must be recognized by std:logging/LogEvent. Any other argument, or a field holding NaN, Infinity, or -Infinity, signals an Error before any text is produced. Rendering invokes no behavior stored in the event.

No callable shape is mechanically recorded for this slot.

Exact module source · Standard-library API · Standard library overview