gossamer/console

Access to the runtime’s debugging console — log, warn, error, groups, counters, timers, and assertions.

See console on MDN.

Values

pub fn clear() -> Nil

Clears the console if the runtime allows it.

pub fn count(label: String) -> Nil

Logs the number of times count has been called with label. Pair with count_reset to reset the counter.

pub fn count_reset(label: String) -> Nil

Resets the counter associated with label.

pub fn debug(data: a) -> Nil

Outputs data to the console at the debug log level.

pub fn dir(item: a) -> Nil

Displays an interactive listing of the properties of item. Most useful when the runtime renders an inspectable tree (browsers, Node REPL).

pub fn dirxml(item: a) -> Nil

Displays an interactive tree of item’s descendant elements when item is a markup element, falling back to a property listing like dir otherwise.

pub fn error(data: a) -> Nil

Outputs data to the console at the error log level.

pub fn group(label: String) -> Nil

Starts a new inline group titled label. Subsequent console output is indented under the group until group_end is called.

pub fn group_collapsed(label: String) -> Nil

Like group, but the group is collapsed by default.

pub fn group_end() -> Nil

Exits the current inline group started by group or group_collapsed.

pub fn info(data: a) -> Nil

Outputs data to the console at the info log level.

pub fn log(data: a) -> Nil

Outputs data to the console at the log log level — the general-purpose logging entry point.

pub fn log_if_false(that condition: Bool, log data: a) -> Nil

Logs data as an error if condition is False. A no-op when the condition holds. Equivalent to JavaScript’s console.assert.

pub fn table(data: a) -> Nil

Displays data as a table. The runtime renders the structure as rows and columns when it can; otherwise falls back to a regular log.

pub fn time(label: String) -> Nil

Starts a timer identified by label. Pair with time_log to read the elapsed time and time_end to stop the timer.

pub fn time_end(label: String) -> Nil

Stops the timer identified by label and logs the elapsed time.

pub fn time_log(label: String) -> Nil

Logs the current elapsed time for the timer identified by label without stopping it.

pub fn trace() -> Nil

Outputs a stack trace to the console at the point of call.

pub fn warn(data: a) -> Nil

Outputs data to the console at the warn log level.

Search Document