Skip to main content

WideEvent

Struct WideEvent 

Source
pub struct WideEvent<K: Key> { /* private fields */ }
Expand description

A wide event — a structured log record that accumulates fields throughout a request/task lifecycle and is emitted as a single JSON line on completion.

Fields are stored in an array indexed by K::as_index() — O(1) lookup with no linear scan. Up to INLINE_CAP (24) Option<Value> slots are inline on the stack; zero heap allocation in the common case. Log entries are stored in a separate SmallVec with inline capacity of 16.

The Serialize impl emits all user entries in enum-variant order, then the "log" key (if any log entries have been accumulated). The "log" key is never declared by the user — it appears automatically.

This type is not constructed directly by users. The wide_log! macro generates a WideLogGuard that owns a WideEvent and manages the thread-local/task-local pointer via current().

Implementations§

Source§

impl<K: Key> WideEvent<K>

Source

pub fn add_path<V: Into<Value<K>>>(&mut self, path: &[K], value: V)

Set a value at a nested path. Traverses/creates intermediate objects.

Source

pub fn inc_path(&mut self, path: &[K])

Source

pub fn dec_path(&mut self, path: &[K])

Source

pub fn add_n_path(&mut self, path: &[K], n: i64)

Source

pub fn append_log_entry(&mut self, level: &'static str, message: &str)

Source

pub fn append_log_entry_static( &mut self, level: &'static str, message: &'static str, )

Append a log entry with a &'static str message — zero-copy.

Source

pub fn to_json(&self) -> Result<String, Error>

Source

pub fn serialize_to<W: Write>(&self, w: &mut W) -> Result<(), Error>

Serialize directly to a writer, bypassing serde entirely. Uses itoa/ryu for zero-allocation number formatting.

Trait Implementations§

Source§

impl<K: Clone + Key> Clone for WideEvent<K>

Source§

fn clone(&self) -> WideEvent<K>

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<K: Key> Debug for WideEvent<K>

Source§

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

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

impl<K: Key> Default for WideEvent<K>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<K: Key> Serialize for WideEvent<K>

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<K> Freeze for WideEvent<K>

§

impl<K> RefUnwindSafe for WideEvent<K>
where K: RefUnwindSafe,

§

impl<K> Send for WideEvent<K>
where K: Send,

§

impl<K> Sync for WideEvent<K>
where K: Sync,

§

impl<K> Unpin for WideEvent<K>
where K: Unpin,

§

impl<K> UnsafeUnpin for WideEvent<K>

§

impl<K> UnwindSafe for WideEvent<K>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.