pub struct Console;Expand description
A console abstraction providing web console API methods.
Methods are associated functions (not instance methods) that internally
access the global Console signal, so callers use Console::log(msg)
without needing to obtain or hold a Console instance.
Implementations§
Source§impl Console
Implements the Console struct providing web console API methods.
impl Console
Implements the Console struct providing web console API methods.
Each method outputs to both the browser developer console and the vConsole panel signal, with appropriate log level classification. Methods are associated functions that internally access the global Console instance, so callers never need to hold a reference.
Sourcepub fn init()
pub fn init()
Initializes the global Console log signal.
Must be called once during application startup before any Console::log,
Console::warn, Console::error, or Console::push calls.
OPT-23: also populates the shared RefCell backing store that
Console::push uses for in-place appends. The RefCell and the
Signal always share the same Vec snapshot — every push
writes to the RefCell first, then re-broadcasts via the signal.
Sourcepub fn log<M>(message: M)
pub fn log<M>(message: M)
Logs an informational message (equivalent to console.log).
The vConsole panel entry is appended only when Console::init has
been called; the browser console output always happens.
§Arguments
M: AsRef<str>- The message to log.
Sourcepub fn warn<M>(message: M)
pub fn warn<M>(message: M)
Logs a warning message (equivalent to console.warn).
The vConsole panel entry is appended only when Console::init has
been called; the browser console output always happens.
§Arguments
M: AsRef<str>- The warning message to log.
Sourcepub fn error<M>(message: M)
pub fn error<M>(message: M)
Logs an error message (equivalent to console.error).
The vConsole panel entry is appended only when Console::init has
been called; the browser console output always happens.
§Arguments
M: AsRef<str>- The error message to log.
Sourcepub fn clear()
pub fn clear()
Clears all log entries from the vConsole panel signal.
No-op when Console::init has not been called yet.
OPT-23: when the shared RefCell backing store is installed,
clears it in place before re-broadcasting an empty vec, so the
two storage sites stay in sync.
Sourcepub fn push(entry: ConsoleEntry)
pub fn push(entry: ConsoleEntry)
OPT-23: append-only mutation API for the vConsole log signal.
Public escape hatch for callers (and tests) that want to push
a ConsoleEntry without going through the log/warn/error
helpers. Uses the shared RefCell backing store for an
in-place append, then re-broadcasts via the signal so existing
reactive subscribers re-render.
Falls back to the signal-only path when Console::init has
not yet installed the shared RefCell.
§Arguments
ConsoleEntry- The console entry to append.