Axle v0.14.1
Package

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

TypeMethod and description
void
__setLevelRaw(level : i32) : void Native: set the raw threshold; an enum can't cross FFI as a value.
i32
__getLevelRaw() : i32 Native: read the raw threshold.
void
setLevel(level : LogLevel) : void Set the process-wide minimum level; calls below it are dropped before
the message is formatted.
LogLevel
getLevel() : LogLevel The current process-wide minimum level.
void
trace(message : string) : void Log message at TRACE (0) — finest detail; dropped unless level <= 0.
void
debug(message : string) : void Log message at DEBUG (10); dropped unless level <= 10.
void
info(message : string) : void Log message at INFO (20) — the default threshold.
void
warn(message : string) : void Log message at WARN (30).
void
error(message : string) : void Log message at ERROR (40) — the highest level, always emitted.
bool
__isEnabledRaw(level : i32) : bool Native: test the raw level against the threshold.
bool
isEnabled(level : LogLevel) : bool Returns true iff a call at level would emit. Wrap expensive
formatting in this guard if you build the message yourself.

Method detail

#__setLevelRaw

__setLevelRaw(level : i32) : void

Native: set the raw threshold; an enum can't cross FFI as a value.

#__getLevelRaw

__getLevelRaw() : i32

Native: read the raw threshold.

#setLevel

setLevel(level : LogLevel) : void

Set the process-wide minimum level; calls below it are dropped before
the message is formatted.

Parameters
level the threshold severity

#getLevel

getLevel() : LogLevel

The current process-wide minimum level.

#trace

trace(message : string) : void

Log message at TRACE (0) — finest detail; dropped unless level <= 0.

Parameters
message text to emit; not formatted at all when the level gates it out.

#debug

debug(message : string) : void

Log message at DEBUG (10); dropped unless level <= 10.

Parameters
message diagnostic text; skipped unformatted below the threshold.

#info

info(message : string) : void

Log message at INFO (20) — the default threshold.

Parameters
message informational text written to stderr with the level prefix.

#warn

warn(message : string) : void

Log message at WARN (30).

Parameters
message warning text written to stderr with the level prefix.

#error

error(message : string) : void

Log message at ERROR (40) — the highest level, always emitted.

Parameters
message error text written to stderr with the level prefix.

#__isEnabledRaw

__isEnabledRaw(level : i32) : bool

Native: test the raw level against the threshold.

#isEnabled

isEnabled(level : LogLevel) : bool

Returns true iff a call at level would emit. Wrap expensive
formatting in this guard if you build the message yourself.

Parameters
level the level to test