Skip to content
CryoCryo home
StdlibSystem

log

Records a program writes about what it is doing, by area and level, sent to one process-wide sink. Not auto-imported.

A Logger names an area and logs at a LogLevel. Logging holds the settings every logger reads — a level for each area and the default one — and the LogSink records go to, which is StandardErrorSink until a program sets its own.

import std::collections::str::{ Str };
import std::log::logger::{ Logger, Logging };

const log: Logger = Logger::new(Str::new("http"));

function main() -> i32 {
    Logging::configure_from_environment(Str::new("APP_LOG")).unwrap();
    log.information(f"listening on port {8080}");
    return 0;
}

With APP_LOG=information, that writes 2026-11-09T14:03:07Z information http: listening on port 8080 to standard error; with it unset, only warnings and errors are written.

The message is an f-string passed as an fmt::Arguments, so it is formatted only when a sink writes it: a record the settings refuse costs one atomic load, and its holes are never rendered.

module log::record;
module log::sink;
module log::logger;

export std::log::record::{ LogLevel, LogRecord };
export std::log::sink::{ LogSink, StandardErrorSink };
export std::log::logger::{ LogSpecificationError, Logger, Logging };
FileWhat it holdsImport
recordLogLevel, LogRecordimport std::log::record;
sinkLogSink, StandardErrorSinkimport std::log::sink;
loggerLogger, Logging, LogSpecificationErrorimport std::log::logger;