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> PartialOrd for Metadata<'a>
impl<'a> PartialOrd for Metadata<'a>
impl<'a> Eq for Metadata<'a>
impl<'a> StructuralPartialEq for Metadata<'a>
Auto Trait Implementations§
impl<'a> Freeze for Metadata<'a>
impl<'a> RefUnwindSafe for Metadata<'a>
impl<'a> Send for Metadata<'a>
impl<'a> Sync for Metadata<'a>
impl<'a> Unpin for Metadata<'a>
impl<'a> UnwindSafe for Metadata<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 24 bytes