Logger Class
Leveled structured logging to stderr. Levels are debug < info < warn < error; entries below the configured level are dropped. SOLI_LOG_LEVEL seeds the initial level (default info).
Logger.debug / info / warn / error(msg, fields?)
Emit one entry. The optional fields hash is merged into the output.
Logger.info("order placed", { "order_id": order["id"], "total": total });
Logger.warn("slow query", { "ms": 812 });
Logger.error("payment failed", { "provider": "stripe" });
Output formats
Text by default: timestamp, level, message, then key=value fields. Set {"json": true} to emit one JSON object per line with ts, level, message plus fields — ready for any log pipeline.
2026-08-22T10:30:00Z [INFO] order placed order_id=42 total=149.7
{"ts":"2026-08-22T10:30:00Z","level":"INFO","message":"order placed","order_id":42}
Logger.configure({ "level": "warn", "json": true });
Logger.level(); # "WARN"
Testing with capture
set_capture(true) records entries into a bounded ring buffer so specs assert on them instead of scraping stderr.
Logger.set_capture(true);
do_work();
assert(Logger.entries().length() > 0);
Logger.set_capture(false); # disables and clears