Struct Metadata

pub struct Metadata<'a> { /* private fields */ }

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.

Records 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) {}
}

# fn main(){}

Implementations

impl<'a> Metadata<'a>

fn builder() -> MetadataBuilder<'a>

Returns a new builder.

fn level(&self) -> Level

The verbosity level of the message.

fn target(&self) -> &'a str

The name of the target of the directive.

Trait Implementations

impl<'a> Clone for Metadata<'a>

fn clone(&self) -> Metadata<'a>

impl<'a> Debug for Metadata<'a>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl<'a> Eq for Metadata<'a>

impl<'a> Hash for Metadata<'a>

fn hash<__H: Hasher>(&self, state: &mut __H)

impl<'a> Ord for Metadata<'a>

fn cmp(&self, other: &Metadata<'a>) -> Ordering

impl<'a> PartialEq for Metadata<'a>

fn eq(&self, other: &Metadata<'a>) -> bool

impl<'a> PartialOrd for Metadata<'a>

fn partial_cmp(&self, other: &Metadata<'a>) -> Option<Ordering>

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> UnsafeUnpin for Metadata<'a>

impl<'a> UnwindSafe for Metadata<'a>

Blanket Implementations

impl<T> Any for Metadata<'a> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Metadata<'a> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Metadata<'a> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for Metadata<'a> where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for Metadata<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Metadata<'a> where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for Metadata<'a> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Metadata<'a> where U: Into<T>,

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto<U> for Metadata<'a> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>