Skip to main content

LogRecord

Struct LogRecord 

Source
pub struct LogRecord {
    pub ts: i64,
    pub level: LogLevel,
    pub message: String,
    pub attrs: BTreeMap<String, AttrValue>,
    pub logger: Option<String>,
    pub seq: i64,
    pub revision: Option<i64>,
}
Expand description

One application log record.

ts is Unix epoch milliseconds, not session-relative: an adapter has no reliable view of when the driver considers the session to have started, so the wall clock is the only clock both sides agree on without negotiating. The driver rebases it onto the session timeline.

Fields§

§ts: i64

Unix epoch milliseconds when the record was produced.

§level: LogLevel

Severity.

§message: String

Human-readable message, already formatted by the source logger.

§attrs: BTreeMap<String, AttrValue>

Flat structured context; sorted so a record serialises the same way twice.

§logger: Option<String>

Logger or channel name, e.g. http or db.pool.

§seq: i64

Per-session counter assigned by the adapter. A gap tells the driver records were dropped upstream rather than lost in transit.

§revision: Option<i64>

Semantic revision current when the record was produced, when known.

Implementations§

Source§

impl LogRecord

Source

pub fn new(level: LogLevel, message: impl Into<String>) -> Self

A record with only the required fields. seq is assigned by the client.

Source

pub fn with_attr( self, key: impl Into<String>, value: impl Into<AttrValue>, ) -> Self

Add one flat attribute.

Source

pub fn with_logger(self, logger: impl Into<String>) -> Self

Name the logger this record came from.

Source

pub fn validate(&self, limits: &Limits) -> Result<(), ValidationError>

Validate against limits, as the driver will.

§Errors

Returns a ValidationError with the shared taxonomy.

Trait Implementations§

Source§

impl Clone for LogRecord

Source§

fn clone(&self) -> LogRecord

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LogRecord

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for LogRecord

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for LogRecord

Source§

fn eq(&self, other: &LogRecord) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for LogRecord

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for LogRecord

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.