std/system/log
std/log — leveled logging to stderr with timestamps.
Format : [epoch millis] [LEVEL] message
The stamp is milliseconds since the Unix epoch, not a calendar
rendering: the raw figure still sorts lexicographically, which is
what a log reader wants of it, and a civil-time conversion is not
something this logger carries. The whole line, terminator
included, reaches stderr in one write, so two threads logging at
the same moment cannot interleave inside a line.
Filtering : a process-wide minimum level (setLevel(L)) gates
emission. Default is INFO. Calls below the threshold are
O(1) — the message is not formatted.
Levels (lowest to highest): TRACE = 0, DEBUG = 10, INFO = 20,
WARN = 30, ERROR = 40.
Free functions
| Type | Method and description |
|---|---|
| __setLevelRaw(level : i32) : void Native: set the raw threshold; an enum can't cross FFI as a value. |
| __getLevelRaw() : i32 Native: read the raw threshold. |
| setLevel(level : LogLevel) : void Set the process-wide minimum level; calls below it are dropped before the message is formatted. |
| getLevel() : LogLevel The current process-wide minimum level. |
| trace(message : string) : void Log message at TRACE (0) — finest detail; dropped unless level <= 0. |
| debug(message : string) : void Log message at DEBUG (10); dropped unless level <= 10. |
| info(message : string) : void Log message at INFO (20) — the default threshold. |
| warn(message : string) : void Log message at WARN (30). |
| error(message : string) : void Log message at ERROR (40) — the highest level, always emitted. |
| __isEnabledRaw(level : i32) : bool Native: test the raw level against the threshold. |
| isEnabled(level : LogLevel) : bool Returns true iff a call at level would emit. Wrap expensiveformatting in this guard if you build the message yourself. |
Method detail
#__setLevelRaw
Native: set the raw threshold; an enum can't cross FFI as a value.
#__getLevelRaw
Native: read the raw threshold.
#setLevel
Set the process-wide minimum level; calls below it are dropped before
the message is formatted.
level the threshold severity#getLevel
The current process-wide minimum level.
#trace
Log message at TRACE (0) — finest detail; dropped unless level <= 0.
message text to emit; not formatted at all when the level gates it out.#debug
Log message at DEBUG (10); dropped unless level <= 10.
message diagnostic text; skipped unformatted below the threshold.#info
Log message at INFO (20) — the default threshold.
message informational text written to stderr with the level prefix.#warn
Log message at WARN (30).
message warning text written to stderr with the level prefix.#error
Log message at ERROR (40) — the highest level, always emitted.
message error text written to stderr with the level prefix.#__isEnabledRaw
Native: test the raw level against the threshold.
#isEnabled
Returns true iff a call at level would emit. Wrap expensive
formatting in this guard if you build the message yourself.
level the level to test