pub struct Logger { /* private fields */ }std only.Expand description
The configured log pipeline.
Implementations§
Source§impl Logger
impl Logger
Sourcepub fn builder() -> LoggerBuilder
pub fn builder() -> LoggerBuilder
Start configuring a logger.
Sourcepub fn threshold_for(&self, target: &str) -> Level
pub fn threshold_for(&self, target: &str) -> Level
The configured filter threshold for target.
Sourcepub fn enabled(&self, target: &str, level: Level) -> bool
pub fn enabled(&self, target: &str, level: Level) -> bool
Returns true if a record with this severity and target would
pass the filter. Use in hot paths to skip field construction
before Self::log.
Sourcepub fn min_level(&self) -> Level
pub fn min_level(&self) -> Level
The lowest severity the filter admits anywhere. Useful for short-circuiting macros at the call site.
Sourcepub fn log(&self, level: Level, message: &str, fields: &[Field<'_>])
pub fn log(&self, level: Level, message: &str, fields: &[Field<'_>])
Emit a record using the empty string as the target. The
simplest entry point; macros prefer Self::try_emit so they
can attach source location.
Sourcepub fn try_log(
&self,
level: Level,
target: &str,
message: &str,
fields: &[Field<'_>],
) -> Result<()>
pub fn try_log( &self, level: Level, target: &str, message: &str, fields: &[Field<'_>], ) -> Result<()>
Emit a record at level with explicit target.
Sink errors are passed to the configured error handler (if any)
and then returned. Use Self::log for fire-and-forget calls.
§Errors
Returns the first sink error; remaining sinks still receive the record so a transient failure on one destination does not starve the others.
Sourcepub fn try_emit(
&self,
metadata: Metadata<'_>,
message: &str,
fields: &[Field<'_>],
) -> Result<()>
pub fn try_emit( &self, metadata: Metadata<'_>, message: &str, fields: &[Field<'_>], ) -> Result<()>
Lowest-level emission entry point. Accepts a fully-constructed
Metadata so the caller (typically a macro) can attach
source location.
The logger augments the metadata with a timestamp (if enabled)
before dispatch. Filtering uses metadata.target and
metadata.level.
§Errors
Returns the first sink error encountered. Other sinks are still attempted; see the type-level docs on dispatch semantics.
Sourcepub fn flush(&self) -> Result<()>
pub fn flush(&self) -> Result<()>
Flush every configured sink. Use during graceful shutdown to drain buffered output.
§Errors
Returns the first flush error. Other sinks are still flushed.
Sourcepub fn sink_count(&self) -> usize
pub fn sink_count(&self) -> usize
Number of installed sinks. Useful for assertions in tests and for logging the logger’s own configuration.