LEARN VOID

Logging

Choose a severity threshold and handle failures at the output boundary.

logging.voidDownload source
use log

func entry(count: i32) -> i32:
    var settings = log.config(minimum = log.level.warn)
    if settings.minimum is log.level.warn:
        return count
    return 0
Input 6Expected result 6

Choose which records qualify

log.config is a value record. A warning threshold admits warnings and errors. This example inspects the configuration without writing a file or console record.

Own the logger

log.open(options) returns a result containing a logger or a failure. Check the results of write, flush and close. write_lazy lets a logger avoid constructing a message when its level is disabled.

Configure rotation deliberately

File logging uses an explicit path, byte limit and backup count. Existing filenames require explicit adoption in an exclusive-writer directory. The logging API has passed cross-platform tests. Its performance review remains open and release is on hold following an unresolved compiler optimizer incident.

Continue learning with File ownership · Error handling.