Skip to main content

Diagnostics

Struct Diagnostics 

Source
pub struct Diagnostics { /* private fields */ }
Expand description

The write-only logging surface.

Holding one is the only way to write a log line in this crate, and it offers no way to read one back.

Implementations§

Source§

impl Diagnostics

Source

pub fn new(floor: Level, sink: Sink) -> Diagnostics

Writes every level at or before floor to sink.

Source

pub fn off() -> Diagnostics

Writes nothing at all. The state the deletion-invariance test runs in, and a legitimate way to run the city.

Source

pub fn floor(&self) -> Option<Level>

The current floor, for status to report. None is off.

Source

pub fn admits(&self, level: Level) -> bool

Whether a level would be written. Offered so a caller can skip building an expensive message, not so it can branch on it.

Source

pub fn write(&mut self, level: Level, site: Site<'_>, message: &str)

Writes one line, if the floor admits it.

The message passes the same secret scan the Ledger uses — the same function, not a second one, because the scanner nobody watches is the one that misses something. A hit is replaced in place: dropping the line would lose the diagnostic entirely, and the surrounding words are usually what the reader needed. A log line marks plainly: see crate::redact::Marker for why history and a log differ in that one argument and in nothing else.

Trait Implementations§

Source§

impl Debug for Diagnostics

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

The sink is not printable, and the floor is the only state worth seeing. Manual rather than derived so a future field does not quietly acquire a Debug that prints what it logged.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.