pub struct Record<'a> {
pub(crate) metadata: Metadata<'a>,
pub(crate) args: Arguments<'a>,
pub(crate) module_path: Option<MaybeStaticStr<'a>>,
pub(crate) file: Option<MaybeStaticStr<'a>>,
pub(crate) line: Option<u32>,
}
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) {}
}
Fields§
§metadata: Metadata<'a>
§args: Arguments<'a>
§module_path: Option<MaybeStaticStr<'a>>
§file: Option<MaybeStaticStr<'a>>
§line: Option<u32>
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> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more