slog

Struct Record

Source
pub struct Record<'a> { /* private fields */ }
Expand description

One logging record

Corresponds to one logging statement like info!(...) and carries all its data: eg. message, immediate key-value pairs and key-value pairs of Logger used to execute it.

Record is passed to a Logger, which delivers it to its own Drain, where actual logging processing is implemented.

Implementations§

Source§

impl<'a> Record<'a>

Source

pub fn new( s: &'a RecordStatic<'a>, msg: &'a Arguments<'a>, kv: BorrowedKV<'a>, ) -> Self

Create a new Record

Most of the time, it is slightly more performant to construct a Record via the record! macro because it enforces that the entire RecordStatic is built at compile-time.

Use this if runtime record creation is a requirement, as is the case with slog-async, for example.

Source

pub fn msg(&self) -> &Arguments<'_>

Get a log record message

Source

pub fn level(&self) -> Level

Get record logging level

Source

pub fn line(&self) -> u32

Get line number

Source

pub fn location(&self) -> &RecordLocation

Get line number

Source

pub fn column(&self) -> u32

Get error column

Source

pub fn file(&self) -> &'static str

Get file path

Source

pub fn tag(&self) -> &str

Get tag

Tag is information that can be attached to Record that is not meant to be part of the normal key-value pairs, but only as an ad-hoc control flag for quick lookup in the Drains. As such should be used carefully and mostly in application code (as opposed to libraries) - where tag meaning across the system can be coordinated. When used in libraries, make sure to prefix it with something reasonably distinct, like create name.

Source

pub fn module(&self) -> &'static str

Get module

Source

pub fn function(&self) -> &'static str

Get function (placeholder)

There’s currently no way to obtain that information in Rust at compile time, so it is not implemented.

It will be implemented at first opportunity, and it will not be considered a breaking change.

Source

pub fn kv(&self) -> BorrowedKV<'_>

Get key-value pairs

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.