Trait tracing_log::NormalizeEvent

source ·
pub trait NormalizeEvent<'a>: Sealed {
    // Required methods
    fn normalized_metadata(&'a self) -> Option<Metadata<'a>>;
    fn is_log(&self) -> bool;
}
Expand description

Extends log Events to provide complete Metadata.

In tracing-log, an Event produced by a log (through AsTrace) has an hard coded “log” target and no file, line, or module_path attributes. This happens because Event requires its Metadata to be 'static, while log::Records provide them with a generic lifetime.

However, these values are stored in the Event’s fields and the normalized_metadata method allows to build a new Metadata that only lives as long as its source Event, but provides complete data.

It can typically be used by Subscribers when processing an Event, to allow accessing its complete metadata in a consistent way, regardless of the source of its source.

Required Methods§

source

fn normalized_metadata(&'a self) -> Option<Metadata<'a>>

If this Event comes from a log, this method provides a new normalized Metadata which has all available attributes from the original log, including file, line, module_path and target. Returns None is the Event is not issued from a log.

source

fn is_log(&self) -> bool

Returns whether this Event represents a log (from the log crate)

Implementations on Foreign Types§

source§

impl<'a> NormalizeEvent<'a> for Event<'a>

Implementors§