pub struct Record<'a> { /* private fields */ }
Expand description
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. Record
s 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§
Source§impl<'a> Record<'a>
impl<'a> Record<'a>
Sourcepub fn builder() -> RecordBuilder<'a>
pub fn builder() -> RecordBuilder<'a>
Returns a new builder.
Sourcepub fn module_path(&self) -> Option<&'a str>
pub fn module_path(&self) -> Option<&'a str>
The module path of the message.
Sourcepub fn module_path_static(&self) -> Option<&'static str>
pub fn module_path_static(&self) -> Option<&'static str>
The module path of the message, if it is a 'static
string.
Sourcepub fn file_static(&self) -> Option<&'static str>
pub fn file_static(&self) -> Option<&'static str>
The source file containing the message, if it is a 'static
string.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Record<'a>
impl<'a> RefUnwindSafe for Record<'a>
impl<'a> !Send for Record<'a>
impl<'a> !Sync for Record<'a>
impl<'a> Unpin for Record<'a>
impl<'a> UnwindSafe for Record<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 128 bytes