Trait Target

Source
pub trait Target:
    Send
    + Sync
    + TargetClone {
    // Required method
    fn write(&self, level: LogLevel, formatted: &str) -> Result<(), Error>;

    // Provided methods
    fn filter_level(&self) -> Option<LogLevel> { ... }
    fn id(&self) -> TargetId { ... }
}
Expand description

Defines an output destination for log messages.

This trait allows the logger to write formatted messages to different destinations such as console, files, or custom targets.

Implementors must be thread-safe (Send + Sync) and cloneable.

Required Methods§

Source

fn write(&self, level: LogLevel, formatted: &str) -> Result<(), Error>

Writes a formatted log message to the target.

§Arguments
  • level - The log level of the message
  • formatted - The formatted log message to write
§Returns

Ok(()) if successful, or an error if the write operation failed

Provided Methods§

Source

fn filter_level(&self) -> Option<LogLevel>

Returns a custom filter level for the target. If the target has a filter level set, log messages with a lower level will be ignored.

Source

fn id(&self) -> TargetId

Returns the target ID for the target. This is used to identify the target in the logger.

Trait Implementations§

Source§

impl Clone for Box<dyn Target>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§