Import std.log.sinks
std.log.sinks
The sinks std.log has: the console's, which writes readable lines to stderr, colored on a terminal that shows colors, and JSON lines, one object a line, to what the program gives. A sink is a Sendable Func(LogRecord), so a program's own is a lambda. Files and rotating files wait for std.io's.
std/log/sinks.fb
Functions
ConsoleSink
function
Public Function ConsoleSink(): Sendable Func(LogRecord)
A sink that writes each line to stderr as LogLine has it, with its time, colored when stderr is a terminal that shows colors and NO_COLOR isn't set. Lines from threads at once don't mix.
ConsoleSink
function
Public Function ConsoleSink(colors: Bool, times: Bool): Sendable Func(LogRecord)
A sink that writes each line to stderr, with its level colored or not, and its time or not.
JsonLinesSink
function
Public Function JsonLinesSink(write: Sendable Func(String)): Sendable Func(LogRecord)
A sink that gives write each line as JSON, an object without line breaks, as JsonLine has it.
LogLine
function
Public Function LogLine(record: LogRecord, times: Bool = True, colors: Bool = False): String
The line as the console's sink writes it: its time in UTC, to the millisecond, its level, its module, its message, and its fields, as name=value, where a name or a value with a space, a quote, an '=', or a control character, or none, is quoted, as JSON quotes it: "2026-10-24T04:12:00.123Z INFO net.http: connected host=example.com port=443". The message's control characters but a tab are escaped as JSON escapes them, so a line stays one line.
JsonLine
function
Public Function JsonLine(record: LogRecord): String
The line as JSON lines have it: an object of its "time", "level", "module", and "message", and then its fields, a number's or a Bool's as it is, each in the order it has them: {"time":"2026-10-24T04:12:00.123Z","level":"info","module":"net","message":"up","port":443}.
Report an issue with this page or with FutureBlitz on GitHub.