[−][src]Struct nj_core::log::Record
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
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 module_path_static(&self) -> Option<&'static str>
[src]
The module path of the message, if it is a 'static
string.
pub fn file(&self) -> Option<&'a str>
[src]
The source file containing the message.
pub fn file_static(&self) -> Option<&'static str>
[src]
The module path of the message, if it is a 'static
string.
pub fn line(&self) -> Option<u32>
[src]
The line containing the message.
pub fn key_values(&self) -> &dyn Source
[src]
The structued key-value pairs associated with the message.
pub fn to_builder(&self) -> RecordBuilder<'_>
[src]
Create a new RecordBuilder
based on this record.
Trait Implementations
impl<'a> AsTrace for Record<'a>
[src]
type Trace = Metadata<'a>
The tracing
type that this type can be converted into.
pub fn as_trace(&self) -> <Record<'a> as AsTrace>::Trace
[src]
impl<'a> Clone for Record<'a>
[src]
impl<'a> Debug for Record<'a>
[src]
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Record<'a>
[src]
impl<'a> !Send for Record<'a>
[src]
impl<'a> !Sync for Record<'a>
[src]
impl<'a> Unpin for Record<'a>
[src]
impl<'a> !UnwindSafe for Record<'a>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,