Struct vector_core::event::LogEvent
source · pub struct LogEvent { /* private fields */ }
Implementations§
source§impl LogEvent
impl LogEvent
sourcepub fn from_str_legacy(msg: impl Into<String>) -> Self
pub fn from_str_legacy(msg: impl Into<String>) -> Self
This used to be the implementation for LogEvent::from(&'str)
, but this is now only
valid for LogNamespace::Legacy
sourcepub fn from_bytes_legacy(msg: &Bytes) -> Self
pub fn from_bytes_legacy(msg: &Bytes) -> Self
This used to be the implementation for LogEvent::from(Bytes)
, but this is now only
valid for LogNamespace::Legacy
pub fn value(&self) -> &Value
pub fn value_mut(&mut self) -> &mut Value
pub fn metadata(&self) -> &EventMetadata
pub fn metadata_mut(&mut self) -> &mut EventMetadata
sourcepub fn namespace(&self) -> LogNamespace
pub fn namespace(&self) -> LogNamespace
This detects the log namespace used at runtime by checking for the existence
of the read-only “vector” metadata, which only exists (and is required to exist)
with the Vector
log namespace.
source§impl LogEvent
impl LogEvent
pub fn new_with_metadata(metadata: EventMetadata) -> Self
sourcepub fn from_parts(value: Value, metadata: EventMetadata) -> Self
pub fn from_parts(value: Value, metadata: EventMetadata) -> Self
Create a LogEvent
from a Value
and EventMetadata
sourcepub fn from_map(map: ObjectMap, metadata: EventMetadata) -> Self
pub fn from_map(map: ObjectMap, metadata: EventMetadata) -> Self
Create a LogEvent
from an ObjectMap
and EventMetadata
sourcepub fn into_parts(self) -> (Value, EventMetadata)
pub fn into_parts(self) -> (Value, EventMetadata)
Convert a LogEvent
into a tuple of its components
pub fn with_batch_notifier(self, batch: &BatchNotifier) -> Self
pub fn with_batch_notifier_option(self, batch: &Option<BatchNotifier>) -> Self
pub fn add_finalizer(&mut self, finalizer: EventFinalizer)
sourcepub fn parse_path_and_get_value(
&self,
path: impl AsRef<str>,
) -> Result<Option<&Value>, PathParseError>
pub fn parse_path_and_get_value( &self, path: impl AsRef<str>, ) -> Result<Option<&Value>, PathParseError>
Parse the specified path
and if there are no parsing errors, attempt to get a reference to a value.
§Errors
Will return an error if path parsing failed.
pub fn get<'a>(&self, key: impl TargetPath<'a>) -> Option<&Value>
sourcepub fn get_by_meaning(&self, meaning: impl AsRef<str>) -> Option<&Value>
pub fn get_by_meaning(&self, meaning: impl AsRef<str>) -> Option<&Value>
Retrieves the value of a field based on it’s meaning. This will first check if the value has previously been dropped. It is worth being aware that if the field has been dropped and then somehow re-added, we still fetch the dropped value here.
sourcepub fn get_mut_by_meaning(
&mut self,
meaning: impl AsRef<str>,
) -> Option<&mut Value>
pub fn get_mut_by_meaning( &mut self, meaning: impl AsRef<str>, ) -> Option<&mut Value>
Retrieves the mutable value of a field based on it’s meaning.
Note that this does not check the dropped fields, unlike get_by_meaning
, since the
purpose of the mutable reference is to be able to modify the value and modifying the dropped
fields has no effect on the resulting event.
sourcepub fn find_key_by_meaning(
&self,
meaning: impl AsRef<str>,
) -> Option<&OwnedTargetPath>
pub fn find_key_by_meaning( &self, meaning: impl AsRef<str>, ) -> Option<&OwnedTargetPath>
Retrieves the target path of a field based on the specified meaning
.
pub fn get_mut<'a>(&mut self, path: impl TargetPath<'a>) -> Option<&mut Value>
pub fn contains<'a>(&self, path: impl TargetPath<'a>) -> bool
sourcepub fn parse_path_and_insert(
&mut self,
path: impl AsRef<str>,
value: impl Into<Value>,
) -> Result<Option<Value>, PathParseError>
pub fn parse_path_and_insert( &mut self, path: impl AsRef<str>, value: impl Into<Value>, ) -> Result<Option<Value>, PathParseError>
Parse the specified path
and if there are no parsing errors, attempt to insert the specified value
.
§Errors
Will return an error if path parsing failed.
pub fn insert<'a>( &mut self, path: impl TargetPath<'a>, value: impl Into<Value>, ) -> Option<Value>
pub fn maybe_insert<'a>( &mut self, path: Option<impl TargetPath<'a>>, value: impl Into<Value>, )
pub fn try_insert<'a>( &mut self, path: impl TargetPath<'a>, value: impl Into<Value>, )
sourcepub fn rename_key<'a>(
&mut self,
from: impl TargetPath<'a>,
to: impl TargetPath<'a>,
)
pub fn rename_key<'a>( &mut self, from: impl TargetPath<'a>, to: impl TargetPath<'a>, )
Rename a key
If to_key
already exists in the structure its value will be overwritten.
pub fn remove<'a>(&mut self, path: impl TargetPath<'a>) -> Option<Value>
pub fn remove_prune<'a>( &mut self, path: impl TargetPath<'a>, prune: bool, ) -> Option<Value>
pub fn keys(&self) -> Option<impl Iterator<Item = KeyString> + '_>
sourcepub fn all_event_fields(
&self,
) -> Option<impl Iterator<Item = (KeyString, &Value)> + Serialize>
pub fn all_event_fields( &self, ) -> Option<impl Iterator<Item = (KeyString, &Value)> + Serialize>
If the event root value is a map, build and return an iterator to event field and value pairs.
TODO: Ideally this should return target paths to be consistent with other LogEvent
methods.
sourcepub fn all_event_fields_skip_array_elements(
&self,
) -> Option<impl Iterator<Item = (KeyString, &Value)> + Serialize>
pub fn all_event_fields_skip_array_elements( &self, ) -> Option<impl Iterator<Item = (KeyString, &Value)> + Serialize>
Similar to LogEvent::all_event_fields
, but doesn’t traverse individual array elements.
sourcepub fn all_metadata_fields(
&self,
) -> Option<impl Iterator<Item = (KeyString, &Value)> + Serialize>
pub fn all_metadata_fields( &self, ) -> Option<impl Iterator<Item = (KeyString, &Value)> + Serialize>
If the metadata root value is a map, build and return an iterator to metadata field and value pairs.
TODO: Ideally this should return target paths to be consistent with other LogEvent
methods.
sourcepub fn convert_to_fields(
&self,
) -> impl Iterator<Item = (KeyString, &Value)> + Serialize
pub fn convert_to_fields( &self, ) -> impl Iterator<Item = (KeyString, &Value)> + Serialize
Returns an iterator of all fields if the value is an Object. Otherwise, a single field is returned with a “message” key. Field names that are could be interpreted as alternate paths (i.e. containing periods, square brackets, etc) are quoted.
sourcepub fn convert_to_fields_unquoted(
&self,
) -> impl Iterator<Item = (KeyString, &Value)> + Serialize
pub fn convert_to_fields_unquoted( &self, ) -> impl Iterator<Item = (KeyString, &Value)> + Serialize
Returns an iterator of all fields if the value is an Object. Otherwise, a single field is returned with a “message” key. Field names are not quoted.
pub fn is_empty_object(&self) -> bool
pub fn as_map(&self) -> Option<&ObjectMap>
pub fn as_map_mut(&mut self) -> Option<&mut ObjectMap>
source§impl LogEvent
impl LogEvent
Log Namespace utility methods. These can only be used when an event has a valid schema definition set (which should be on every event in transforms and sinks).
sourcepub fn message_path(&self) -> Option<&OwnedTargetPath>
pub fn message_path(&self) -> Option<&OwnedTargetPath>
Fetches the “message” path of the event. This is either from the “message” semantic meaning (Vector namespace) or from the message key set on the “Global Log Schema” (Legacy namespace).
sourcepub fn timestamp_path(&self) -> Option<&OwnedTargetPath>
pub fn timestamp_path(&self) -> Option<&OwnedTargetPath>
Fetches the “timestamp” path of the event. This is either from the “timestamp” semantic meaning (Vector namespace) or from the timestamp key set on the “Global Log Schema” (Legacy namespace).
sourcepub fn host_path(&self) -> Option<&OwnedTargetPath>
pub fn host_path(&self) -> Option<&OwnedTargetPath>
Fetches the host
path of the event. This is either from the “host” semantic meaning (Vector namespace)
or from the host key set on the “Global Log Schema” (Legacy namespace).
sourcepub fn source_type_path(&self) -> Option<&OwnedTargetPath>
pub fn source_type_path(&self) -> Option<&OwnedTargetPath>
Fetches the source_type
path of the event. This is either from the source_type
Vector metadata field (Vector namespace)
or from the source_type
key set on the “Global Log Schema” (Legacy namespace).
sourcepub fn get_message(&self) -> Option<&Value>
pub fn get_message(&self) -> Option<&Value>
Fetches the message
of the event. This is either from the “message” semantic meaning (Vector namespace)
or from the message key set on the “Global Log Schema” (Legacy namespace).
sourcepub fn get_timestamp(&self) -> Option<&Value>
pub fn get_timestamp(&self) -> Option<&Value>
Fetches the timestamp
of the event. This is either from the “timestamp” semantic meaning (Vector namespace)
or from the timestamp key set on the “Global Log Schema” (Legacy namespace).
sourcepub fn remove_timestamp(&mut self) -> Option<Value>
pub fn remove_timestamp(&mut self) -> Option<Value>
Removes the timestamp
from the event. This is either from the “timestamp” semantic meaning (Vector namespace)
or from the timestamp key set on the “Global Log Schema” (Legacy namespace).
sourcepub fn get_host(&self) -> Option<&Value>
pub fn get_host(&self) -> Option<&Value>
Fetches the host
of the event. This is either from the “host” semantic meaning (Vector namespace)
or from the host key set on the “Global Log Schema” (Legacy namespace).
sourcepub fn get_source_type(&self) -> Option<&Value>
pub fn get_source_type(&self) -> Option<&Value>
Fetches the source_type
of the event. This is either from the source_type
Vector metadata field (Vector namespace)
or from the source_type
key set on the “Global Log Schema” (Legacy namespace).
Trait Implementations§
source§impl AsMut<LogEvent> for TraceEvent
impl AsMut<LogEvent> for TraceEvent
source§impl AsRef<LogEvent> for TraceEvent
impl AsRef<LogEvent> for TraceEvent
source§impl<'de> Deserialize<'de> for LogEvent
impl<'de> Deserialize<'de> for LogEvent
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl EstimatedJsonEncodedSizeOf for LogEvent
impl EstimatedJsonEncodedSizeOf for LogEvent
fn estimated_json_encoded_size_of(&self) -> JsonSize
source§impl EventContainer for LogEvent
impl EventContainer for LogEvent
source§fn into_events(self) -> Self::IntoIter
fn into_events(self) -> Self::IntoIter
Event
.source§impl<K, V> Extend<(K, V)> for LogEvent
impl<K, V> Extend<(K, V)> for LogEvent
source§fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl Finalizable for LogEvent
impl Finalizable for LogEvent
source§fn take_finalizers(&mut self) -> EventFinalizers
fn take_finalizers(&mut self) -> EventFinalizers
source§impl<'a> From<&'a mut LogEvent> for EventMutRef<'a>
impl<'a> From<&'a mut LogEvent> for EventMutRef<'a>
source§impl From<LogEvent> for EventArray
impl From<LogEvent> for EventArray
source§impl From<LogEvent> for TraceEvent
impl From<LogEvent> for TraceEvent
source§impl MaybeAsLogMut for LogEvent
impl MaybeAsLogMut for LogEvent
fn maybe_as_log_mut(&mut self) -> Option<&mut LogEvent>
source§impl Visit for LogEvent
impl Visit for LogEvent
Note that tracing::field::Field
containing dots and other special characters will be treated as a single segment.
source§fn record_str(&mut self, field: &Field, value: &str)
fn record_str(&mut self, field: &Field, value: &str)
source§fn record_debug(&mut self, field: &Field, value: &dyn Debug)
fn record_debug(&mut self, field: &Field, value: &dyn Debug)
fmt::Debug
.source§fn record_i64(&mut self, field: &Field, value: i64)
fn record_i64(&mut self, field: &Field, value: i64)
source§fn record_u64(&mut self, field: &Field, value: u64)
fn record_u64(&mut self, field: &Field, value: u64)
source§fn record_bool(&mut self, field: &Field, value: bool)
fn record_bool(&mut self, field: &Field, value: bool)
§fn record_f64(&mut self, field: &Field, value: f64)
fn record_f64(&mut self, field: &Field, value: f64)
§fn record_i128(&mut self, field: &Field, value: i128)
fn record_i128(&mut self, field: &Field, value: i128)
§fn record_u128(&mut self, field: &Field, value: u128)
fn record_u128(&mut self, field: &Field, value: u128)
§fn record_bytes(&mut self, field: &Field, value: &[u8])
fn record_bytes(&mut self, field: &Field, value: &[u8])
§fn record_error(&mut self, field: &Field, value: &(dyn Error + 'static))
fn record_error(&mut self, field: &Field, value: &(dyn Error + 'static))
Error
. Read moreimpl StructuralPartialEq for LogEvent
Auto Trait Implementations§
impl Freeze for LogEvent
impl !RefUnwindSafe for LogEvent
impl Send for LogEvent
impl Sync for LogEvent
impl Unpin for LogEvent
impl !UnwindSafe for LogEvent
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
§impl<T> FromLuaMulti for Twhere
T: FromLua,
impl<T> FromLuaMulti for Twhere
T: FromLua,
§fn from_lua_multi(values: MultiValue, lua: &Lua) -> Result<T, Error>
fn from_lua_multi(values: MultiValue, lua: &Lua) -> Result<T, Error>
fn from_lua_args( args: MultiValue, i: usize, to: Option<&str>, lua: &Lua, ) -> Result<T, Error>
unsafe fn from_stack_multi(nvals: i32, lua: &RawLua) -> Result<T, Error>
unsafe fn from_stack_args( nargs: i32, i: usize, to: Option<&str>, lua: &RawLua, ) -> Result<T, Error>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoLuaMulti for Twhere
T: IntoLua,
impl<T> IntoLuaMulti for Twhere
T: IntoLua,
§fn into_lua_multi(self, lua: &Lua) -> Result<MultiValue, Error>
fn into_lua_multi(self, lua: &Lua) -> Result<MultiValue, Error>
unsafe fn push_into_stack_multi(self, lua: &RawLua) -> Result<i32, Error>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
§impl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
impl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
type Error = <Target as OctetsFrom<Source>>::Error
§fn try_octets_into(
self,
) -> Result<Target, <Source as OctetsInto<Target>>::Error>
fn try_octets_into( self, ) -> Result<Target, <Source as OctetsInto<Target>>::Error>
§fn octets_into(self) -> Targetwhere
Self::Error: Into<Infallible>,
fn octets_into(self) -> Targetwhere
Self::Error: Into<Infallible>,
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
] or
a color-specific method, such as [OwoColorize::green
], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
] or
a color-specific method, such as [OwoColorize::on_yellow
], Read more