[][src]Struct log::Record

pub struct Record<'a> { /* fields omitted */ }

The "payload" of a log message.

Use

Record structures are passed as parameters to the log method of the Log trait. Logger implementors manipulate these structures in order to display log messages. Records are automatically created by the log! macro and so are not seen by log users.

Note that the level() and target() accessors are equivalent to self.metadata().level() and self.metadata().target() respectively. These methods are provided as a convenience for users of this structure.

Example

The following example shows a simple logger that displays the level, module path, and message of any Record that is passed to it.

struct SimpleLogger;

impl log::Log for SimpleLogger {
   fn enabled(&self, metadata: &log::Metadata) -> bool {
       true
   }

   fn log(&self, record: &log::Record) {
       if !self.enabled(record.metadata()) {
           return;
       }

       println!("{}:{} -- {}",
                record.level(),
                record.target(),
                record.args());
   }
   fn flush(&self) {}
}

Methods

impl<'a> Record<'a>[src]

pub fn builder() -> RecordBuilder<'a>[src]

Returns a new builder.

pub fn args(&self) -> &Arguments<'a>[src]

The message body.

pub fn metadata(&self) -> &Metadata<'a>[src]

Metadata about the log directive.

pub fn level(&self) -> Level[src]

The verbosity level of the message.

pub fn target(&self) -> &'a str[src]

The name of the target of the directive.

pub fn module_path(&self) -> Option<&'a str>[src]

The module path of the message.

pub fn file(&self) -> Option<&'a str>[src]

The source file containing the message.

pub fn line(&self) -> Option<u32>[src]

The line containing the message.

pub fn key_values(&self) -> ErasedSource[src]

The key value pairs attached to this record.

Pairs aren't guaranteed to be unique (the same key may be repeated with different values).

pub fn to_builder(&self) -> RecordBuilder[src]

Get a builder from this record.

Values on the builder will be preset from the record.

Trait Implementations

impl<'a> Clone for Record<'a>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'a> Debug for Record<'a>[src]

Auto Trait Implementations

impl<'a> !Send for Record<'a>

impl<'a> !Sync for Record<'a>

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]