Struct log::Record [] [src]

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]

[src]

Returns a new builder.

[src]

The message body.

[src]

Metadata about the log directive.

[src]

The verbosity level of the message.

[src]

The name of the target of the directive.

[src]

The module path of the message.

[src]

The source file containing the message.

[src]

The line containing the message.

Trait Implementations

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

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

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

[src]

Formats the value using the given formatter. Read more