🛈 Note: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem.

For the release documentation, please see docs.rs, instead.

tracing_log

Trait 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 collectors 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>

Source§

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

Source§

fn is_log(&self) -> bool

Implementors§