Skip to main content

LogSink

Trait LogSink 

Source
pub trait LogSink: Sync {
    // Required method
    fn log(&self, record: &Record<'_>);

    // Provided methods
    fn flush(&self) { ... }
    fn reentrant(&self) -> bool { ... }
}
Expand description

Backend a log record is delivered to.

Implementations must be Sync so the dispatcher can hold them in &'static [&dyn LogSink]. ISR-safety is per-impl.

Required Methods§

Source

fn log(&self, record: &Record<'_>)

Render record. Called only when the record’s severity passes both the compile-time ceiling AND the Logger’s runtime threshold.

Provided Methods§

Source

fn flush(&self)

Optional flush hook (default no-op).

Source

fn reentrant(&self) -> bool

Whether log may run in several contexts at once: threads, CPUs and interrupts.

A re-entrant sink gets every record directly, in the context that raised it, so concurrent loggers never queue behind one another for it. A sink that is not (the default) is entered one record at a time behind the process-wide dispatch guard, and a record that finds the guard held waits in the hold queue for it, as before.

Say true only when log is safe concurrently AND never logs through nros_log itself. A re-entrant sink that does log is not recursed into without bound: past REENTRANT_DEPTH nested or concurrent deliveries, a record takes the guarded path for every sink. Records from different contexts may reach a re-entrant sink interleaved, in the order they were raised.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl LogSink for PlatformSink

Source§

fn reentrant(&self) -> bool

Issue 2762 – a property of the linked PORT, stated by the feature that port’s build enables (reentrant-log-write).

Source§

fn log(&self, record: &Record<'_>)

Source§

fn flush(&self)

Implementors§