OxL Reference

data log

Namespace of the logging functions: log.info("…").

Example:

oxl✓ checked in CI
use std.obs { log }

fn main() io {
  let id = 42
  log.info("order {id} paid")
  print("logged")
}
Output
logged
pub(api) data log

Thread safety. safe from any task; records of different tasks may interleave, each one is written whole.

Since. 1.0.0-beta

Methods

trace(msg: str) io
Very detailed diagnostics.
debug(msg: str) io
Diagnostics for developers.
info(msg: str) io
Normal events worth recording.
warn(msg: str) io
Something unexpected that the program handled.
error(msg: str) io
An operation failed.
at(level: Level, msg: str) io
Logs at a level chosen at run time (log.at(Level.Warn, "…")).
level() -> Level io
Current threshold
setLevel(level: Level) io
Changes the threshold of this process (the start-up value comes from --log-level / OXL_LOG).
enabled(level: Level) -> bool io
True when a record at level would be written; guard expensive field computation with it.
setJson(on: bool) io
Switches between text (false) and JSON-lines (true) output.
isJson() -> bool io
True when the output is JSON lines.

Defined in: std/obs/obs.oxl:101

See also