std:logging/TextFormatter
std:logging/TextFormatter
Section titled “std:logging/TextFormatter”Canonical occurrence:
protos/lib/logging/TextFormatter.protos· Protos revision:e99b712ecf658a527b1fe82c8beba2c1286d8dc9.
Deterministic plain-text rendering of std:logging/LogEvent values. Each
event renders as exactly one line with no line terminator, source metadata,
color, or terminal control sequence:
LINE = [TIMESTAMP " "] LEVEL " " STRING [" " MAP] [" error=true"]VALUE = "null" | "true" | "false" | INTEGER | FLOAT | STRING | ARRAY | MAPARRAY = "[" [VALUE (", " VALUE)*] "]"MAP = "{" [STRING "=" VALUE (", " STRING "=" VALUE)*] "}"For example ERROR "request failed" {"requestId"="r-7"} error=true.
TIMESTAMP appears exactly when the event has a timestamp and is
std:datetime/ISO8601.formatInstant of it, in UTC with the Z designator,
for example 1970-01-01T00:00:00.000000001Z DEBUG "tick". An instant
outside the civil range that format supports signals an Error; there is no
other timestamp spelling.
The fields Map is omitted when empty, and error=true appears exactly when
an Error is attached; the attached Error is never inspected, so every Error
renders the same marker, distinct from a field named "error".
Strings, including the message and Map keys, are double-quoted. ", \,
LF, CR, and TAB render as \", \\, \n, \r, and \t; the remaining
C0 controls, DEL, the C1 controls U+0080 to U+009F, U+2028, and U+2029
render as \u{HEX} with uppercase hexadecimal digits and no leading zeros.
Every other Unicode scalar is kept exactly, without normalization.
Map entries render in ascending order of their keys’ Unicode scalar sequences: the first differing scalar decides, and a proper prefix comes first. The same order applies at every depth; Map iteration order never matters.
Integers render in canonical base 10. Floats render as NaN, Infinity,
-Infinity, 0.0, -0.0, or, for other values, from the decimal with the
fewest significant digits that round-trips to the same binary64 value (the
closest such decimal; an exact tie takes the even last digit). With digits
d (k of them) and value d * 10^(n - k), the layout is d followed by
n - k zeros and .0 when k <= n <= 21; d with a . after its first
n digits when 0 < n <= 21; 0., -n zeros, and d when
-6 < n <= 0; and otherwise the first digit, . and the remaining digits
when k > 1, then e, the sign + or -, and |n - 1|. A negative value
is prefixed with -. Every finite Float therefore renders with a . or an
exponent and never looks like an Integer.
Observable top-level slots
Section titled “Observable top-level slots”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.
format
Section titled “format”Answers the plain-text line of event, which must be recognized by
std:logging/LogEvent; any other argument, or a timestamp that
std:datetime/ISO8601.formatInstant cannot write, signals an Error.
Rendering invokes no behavior stored in the event.
Mechanical facts
Section titled “Mechanical facts”No callable shape is mechanically recorded for this slot.
- Source occurrence:
protos/lib/logging/TextFormatter.protos:66 - Exact source page: open in the source browser
Exact module source · Standard-library API · Standard library overview