Skip to main content

ConsoleSink

Trait ConsoleSink 

Source
pub trait ConsoleSink:
    Debug
    + Send
    + Sync
    + 'static {
    // Required method
    fn emit(&self, entry: &ConsoleEntry);

    // Provided methods
    fn styled_for(&self, _level: ConsoleLevel) -> bool { ... }
    fn clear(&self) { ... }
}
Expand description

Receiver for console entries as they are produced.

Installed via ConsoleCapture::with_sink / ConsoleOptions::sink by hosts that want live output instead of a buffer drained at the end. emit runs on the VM thread inside the console.* call, so it must not block for long.

Required Methods§

Source

fn emit(&self, entry: &ConsoleEntry)

Provided Methods§

Source

fn styled_for(&self, _level: ConsoleLevel) -> bool

Whether rendered values may carry ANSI styling. Node colours util.inspect output only when the stream is a terminal — and log and error go to different streams, so the answer is per level. A sink writing to a pipe (and the buffered no-sink path) answers false.

Source

fn clear(&self)

console.clear(). Default no-op, like Node’s on a non-terminal stream.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§