Skip to main content

Module log

Module log 

Source
Expand description

Structured logging for every app built from the Framework: a level, a target (a board id, http, app), a message and named fields. Records go to a rotating JSON Lines file under the state directory and to an in-memory ring buffer the log viewer reads. Every message and field value passes through redact first, so a token or an Authorization header never reaches a file.

Code builds its handle with Logger::new, a board with its id as the target. Before init runs, records stay in the buffer, so tests never touch the file system.

Structs§

Config
Where and how much to log.
Logger
A handle that writes records for one target.
Record
One log line.

Enums§

Level
How much a record matters, most important first.

Constants§

BUFFER_RECORDS
How many records the ring buffer keeps for the viewer.
LEVEL_ENV
The environment variable that overrides the stored level at startup.

Functions§

default_directory
<state dir>/subspace/logs, the default log directory.
directory
The directory the log file is in, once init ran.
init
Opens the log file and starts writing records to it. SUBSPACE_LOG in the environment overrides config.level.
level
The level records must reach to be kept.
path
The actual live path of the installed file writer, not a default location.
recent
The buffered records, oldest first.
recent_after
The buffered records after sequence seq, oldest first.
redact
text with every credential it holds masked.
set_level