Struct Metadata

struct Metadata<'a> { ... }

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: &Self) -> Level

The verbosity level of the message.

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

The name of the target of the directive.

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

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

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

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

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

impl<'a> Freeze for Metadata<'a>

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

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

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

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

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

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

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

fn partial_cmp(self: &Self, other: &Metadata<'a>) -> $crate::option::Option<$crate::cmp::Ordering>

impl<'a> RefUnwindSafe for Metadata<'a>

impl<'a> Send for Metadata<'a>

impl<'a> StructuralPartialEq for Metadata<'a>

impl<'a> Sync for Metadata<'a>

impl<'a> Unpin for Metadata<'a>

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

impl<T> Any for Metadata<'a>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Metadata<'a>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Metadata<'a>

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

impl<T> CloneToUninit for Metadata<'a>

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

impl<T> From for Metadata<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Metadata<'a>

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for Metadata<'a>

fn into(self: 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 for Metadata<'a>

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

impl<T, U> TryInto for Metadata<'a>

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