Standard library · The command line
cli/log
Imported as import "cli/log" as log, its names are then log.…. Every signature below is the one the checker infers.
Types
Log
Log(name: Str, level: Int, to: Int)
Functions
fn debug_level() -> Int
log.level_name(log.debug_level()) # => DEBUG
fn info_level() -> Int
log.level_name(log.info_level()) # => INFO
fn warn_level() -> Int
log.level_name(log.warn_level()) # => WARN
fn error_level() -> Int
log.level_name(log.error_level()) # => ERROR
fn new(name: Str) -> Log
l = log.new("db") l.name # => db log.says(l, log.info_level()) # => true log.says(l, log.debug_level()) # => false
fn from_env(name: Str) -> Log
The level from the RILL_LOG variable — debug, info, warn, error, or off — and info when it is unset or says something else.
import "cli/env" as env env.set("RILL_LOG", "warn") log.says(log.from_env("x"), log.info_level()) # => false env.set("RILL_LOG", "nonsense") log.says(log.from_env("x"), log.info_level()) # => true env.unset("RILL_LOG")
fn level_named(word: Str) -> Int
log.level_named("warn") == log.warn_level() # => true log.level_named("loud") == log.info_level() # => true
fn level_name(level: Int) -> Str
log.level_name(log.warn_level()) # => WARN
fn at(l: Log, level: Int) -> Log
l = log.at(log.new("x"), log.error_level()) log.says(l, log.warn_level()) # => false log.says(l, log.error_level()) # => true
fn quiet(l: Log) -> Log
log.says(log.quiet(log.new("x")), log.warn_level()) # => false
fn named(l: Log, name: Str) -> Log
log.named(log.new("app"), "db").name # => db
fn to_stdout(l: Log) -> Log
Writes to standard output instead — for a log that is the program's output, as a server's access log is.
l = log.to_stdout(log.new("access")) l.to # => 1
fn debug(l: Log, msg: Str) -> Unit
l = log.at(log.new("x"), log.debug_level()) log.debug(l, "a detail") # written, since the level allows it
fn info(l: Log, msg: Str) -> Unit
log.info(log.new("x"), "started")
fn warn(l: Log, msg: Str) -> Unit
log.warn(log.new("x"), "slow request")
fn error(l: Log, msg: Str) -> Unit
log.error(log.new("x"), "cannot open the file")
fn says(l: Log, level: Int) -> Bool
log.says(log.new("x"), log.error_level()) # => true
fn line(l: Log, level: Int, msg: Str, when: Str) -> Str
The line as it is written: time, level padded to five, name, message.
log.line(log.new("http"), log.info_level(), "up", "2026-09-15T21:04:05Z") # => 2026-09-15T21:04:05Z INFO http up
Tests
test_levelstest_the_linetest_it_writes