Skip to content

Commit

Permalink
docs: clarify and improve LogWriter documentation for feature-based b…
Browse files Browse the repository at this point in the history
…ehavior

- Removed trait name in description.
- Expanded the description of the `LogWriter` trait to clarify its behavior when the `uniffi` feature is enabled or disabled.
- Improved explanation of the trait’s responsibilities, including handling log messages and forwarding to outputs.
  • Loading branch information
enigbe committed Dec 16, 2024
1 parent f32d7e8 commit 283fe85
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,22 @@ impl<'a> From<Record<'a>> for LogRecord<'a> {
}
}

/// LogWriter trait encapsulating the operations required of a
/// logger's writer.
/// Defines the behavior required for writing log records.
///
/// Implementors of this trait are responsible for handling log messages,
/// which may involve formatting, filtering, and forwarding them to specific
/// outputs.
#[cfg(not(feature = "uniffi"))]
pub trait LogWriter: Send + Sync + Debug {
/// Log the record.
fn log<'a>(&self, record: LogRecord<'a>);
}

/// Defines the behavior required for writing log records.
///
/// This version is used when the `uniffi` feature is enabled.
/// It is similar to the non-`uniffi` version, but it omits the lifetime parameter
/// for the `LogRecord`, as the Uniffi-exposed interface cannot handle lifetimes.
#[cfg(feature = "uniffi")]
pub trait LogWriter: Send + Sync + Debug {
/// Log the record.
Expand Down

0 comments on commit 283fe85

Please sign in to comment.