pub struct Record<'a> { /* private fields */ }Expand description
Represents a log record.
§Use
Record structures are passed as arguments to methods Logger::log.
Loggers forward these structures to its sinks, then sink implementors
manipulate these structures in order to process log records. Records are
automatically created by log macros and so are not seen by log users.
Implementations§
Source§impl<'a> Record<'a>
impl<'a> Record<'a>
Sourcepub fn to_owned(&self) -> RecordOwned
pub fn to_owned(&self) -> RecordOwned
Creates a RecordOwned that doesn’t have lifetimes.
Sourcepub fn logger_name(&self) -> Option<&str>
pub fn logger_name(&self) -> Option<&str>
Gets the logger name.
Sourcepub fn level(&self) -> Level
pub fn level(&self) -> Level
Gets the level.
Examples found in repository?
examples/04-format.rs (line 54)
46 fn format(
47 &self,
48 record: &Record,
49 dest: &mut StringBuf,
50 ctx: &mut FormatterContext,
51 ) -> spdlog::Result<()> {
52 let style_range_begin = dest.len();
53
54 dest.write_str(&record.level().as_str().to_ascii_uppercase())
55 .map_err(spdlog::Error::FormatRecord)?;
56
57 let style_range_end = dest.len();
58
59 writeln!(dest, " {}", record.payload()).map_err(spdlog::Error::FormatRecord)?;
60
61 ctx.set_style_range(Some(style_range_begin..style_range_end));
62 Ok(())
63 }Sourcepub fn payload(&self) -> &str
pub fn payload(&self) -> &str
Gets the payload.
Examples found in repository?
examples/04-format.rs (line 59)
46 fn format(
47 &self,
48 record: &Record,
49 dest: &mut StringBuf,
50 ctx: &mut FormatterContext,
51 ) -> spdlog::Result<()> {
52 let style_range_begin = dest.len();
53
54 dest.write_str(&record.level().as_str().to_ascii_uppercase())
55 .map_err(spdlog::Error::FormatRecord)?;
56
57 let style_range_end = dest.len();
58
59 writeln!(dest, " {}", record.payload()).map_err(spdlog::Error::FormatRecord)?;
60
61 ctx.set_style_range(Some(style_range_begin..style_range_end));
62 Ok(())
63 }Sourcepub fn source_location(&self) -> Option<&SourceLocation>
pub fn source_location(&self) -> Option<&SourceLocation>
Gets the source location.
Sourcepub fn time(&self) -> SystemTime
pub fn time(&self) -> SystemTime
Gets the time when the record was created.
Sourcepub fn key_values(&self) -> KeyValues<'_>
pub fn key_values(&self) -> KeyValues<'_>
Gets the key-values.
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§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)