pub trait MessageImpl:
Send
+ Sync
+ Any {
// Required methods
fn level(&self) -> &dyn Display;
fn content(&self) -> &dyn Display;
fn instant(&self) -> SystemTime;
fn as_any(&self) -> &dyn Any;
}Expand description
A trait for Message implementations that can be formatted and downcast.
This trait is the core of the rust_timber extensibility. It allows the logger
to handle standard text, JSON, or complex Error objects through type erasure.
Required Methods§
Sourcefn level(&self) -> &dyn Display
fn level(&self) -> &dyn Display
Returns the log level (e.g., “INFO”, “DEBUG”) as a displayable object.
Using &dyn Display ensures zero-copy for static string levels.
Sourcefn content(&self) -> &dyn Display
fn content(&self) -> &dyn Display
Returns the message body content. This allows for deferred formatting of complex types like JSON or Error objects.
Sourcefn instant(&self) -> SystemTime
fn instant(&self) -> SystemTime
Returns the exact SystemTime when the message was created. Crucial for maintaining chronological order in asynchronous logging.
Implementors§
impl MessageImpl for ErrorMessageImpl
impl MessageImpl for JsonMessageImpl
Available on crate feature
json only.