pub struct Metadata<'a> { /* private fields */ }
Expand description
Metadata about a log message.
Use
Metadata
structs are created when users of the library use
logging macros.
They are consumed by implementations of the Log
trait in the
enabled
method.
Record
s use Metadata
to determine the log message’s severity
and target.
Users should use the log_enabled!
macro in their code to avoid
constructing expensive log messages.
Examples
ⓘ
use log::{Record, Level, Metadata};
struct MyLogger;
impl log::Log for MyLogger {
fn enabled(&self, metadata: &Metadata) -> bool {
metadata.level() <= Level::Info
}
fn log(&self, record: &Record) {
if self.enabled(record.metadata()) {
println!("{} - {}", record.level(), record.args());
}
}
fn flush(&self) {}
}
Implementations§
Trait Implementations§
source§impl<'a> Ord for Metadata<'a>
impl<'a> Ord for Metadata<'a>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<'a> PartialEq<Metadata<'a>> for Metadata<'a>
impl<'a> PartialEq<Metadata<'a>> for Metadata<'a>
source§impl<'a> PartialOrd<Metadata<'a>> for Metadata<'a>
impl<'a> PartialOrd<Metadata<'a>> for Metadata<'a>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more