Struct Record
pub struct Record<'a> { /* private fields */ }
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) {}
}
Implementations
impl<'a> Record<'a>
fn builder() -> RecordBuilder<'a>Returns a new builder.
fn args(&self) -> &Arguments<'a>The message body.
fn metadata(&self) -> &Metadata<'a>Metadata about the log directive.
fn level(&self) -> LevelThe verbosity level of the message.
fn target(&self) -> &'a strThe name of the target of the directive.
fn module_path(&self) -> Option<&'a str>The module path of the message.
fn module_path_static(&self) -> Option<&'static str>The module path of the message, if it is a
'staticstring.fn file(&self) -> Option<&'a str>The source file containing the message.
fn file_static(&self) -> Option<&'static str>The source file containing the message, if it is a
'staticstring.fn line(&self) -> Option<u32>The line containing the message.
Trait Implementations
impl<'a> Clone for Record<'a>
fn clone(&self) -> Self
impl<'a> Debug for Record<'a>
fn fmt(&self, f: &mut Formatter<'_>) -> Result