Loggable

Trait Loggable 

Source
pub trait Loggable {
    // Required method
    fn to_message(self) -> Message;
}
Expand description

The Loggable trait acts as a compile-time dispatcher for the Logger.

It utilizes Rust’s monomorphization (static dispatch) to provide a pseudo-overloaded API. Each implementation handles a specific “Log Shape,” ensuring high performance and clear type separation without runtime overhead.

Required Methods§

Source

fn to_message(self) -> Message

Converts the implementing type into a unified Message object.

Implementations on Foreign Types§

Source§

impl<S: Into<Cow<'static, str>>> Loggable for (S, &'static str)

Implementation for static string slices. This is the “Hot Path”—zero allocation is required for the message content.

Source§

impl<S: Into<Cow<'static, str>>> Loggable for (S, &String)

Implementation for String references. Performs a .clone() to satisfy the 'static requirement of the Logger.

Source§

impl<S: Into<Cow<'static, str>>> Loggable for (S, Cow<'static, str>)

Implementation for Cow (Copy-on-Write) strings. Handles both borrowed and owned data efficiently.

Source§

impl<S: Into<Cow<'static, str>>> Loggable for (S, Value)

Available on crate feature json only.

Implementation for structured JSON data. Requires feature json.

Source§

impl<S: Into<Cow<'static, str>>> Loggable for (S, Box<dyn Error + Send + Sync>)

Implementation for Standard Library Errors. Wraps the error in a Box for rich exception logging.

Source§

impl<S: Into<Cow<'static, str>>> Loggable for (S, String)

Implementation for owned Strings. Takes ownership of the string, moving it into the Message without copying.

Implementors§

Source§

impl Loggable for Message

Identity implementation: Allows pre-constructed Messages to be logged directly.