Skip to main content

LogGroup

Struct LogGroup 

Source
pub struct LogGroup {
    pub id: Uuid,
    pub variables: HashMap<usize, Token>,
    /* private fields */
}
Expand description

Represents a logical grouping of similar log records.

A LogGroup is characterized by a base event (a Record) and a collection of example records that match the group’s pattern. It also tracks variables (wildcards) within the log pattern.

Fields§

§id: Uuid

The unique identifier for this log group.

§variables: HashMap<usize, Token>

A map of variable positions (offset) to their Token type within the event pattern.

Implementations§

Source§

impl LogGroup

Source

pub fn new(event: Record) -> Self

Creates a new LogGroup from an initial Record.

The provided event becomes the base record for the group, and is also added as the first example.

§Arguments
  • event - The initial Record that defines this log group.
§Returns

A new LogGroup instance.

Source

pub fn add_example(&mut self, rec: Record)

Adds a new example Record to the log group.

This method also attempts to discover new variables (wildcards) by comparing the new record with the group’s base event and updates the group’s variable map.

§Arguments
  • rec - The Record to add as an example.
Source

pub fn event(&self) -> &Record

Returns a reference to the base event (Record) of this log group.

This record represents the generalized pattern of the log group.

§Returns

A reference to the Record that is the base event.

Source

pub fn base_record(&self) -> &Record

Returns a reference to the base record of the log group.

This is an alias for event().

§Returns

A reference to the Record that is the base record.

Source

pub fn examples(&self) -> &Vec<Record>

Returns a slice of the example records stored in this log group.

These are the actual log lines that have been clustered into this group.

§Returns

A slice (&Vec<Record>) of the example records.

Source

pub fn discover_variables(&self, rec: &Record) -> Result<Vec<Wildcard>, Error>

Compares a given Record with the log group’s base event to identify variable positions.

Positions where the tokens differ between the record and the base event, and are not already identified as variables, are considered new variables.

§Arguments
  • rec - The Record to compare against the base event.
§Returns

A Result containing a Vec<Wildcard> representing the newly discovered variable positions, or an anyhow::Error if the comparison fails.

Source

pub fn len(&self) -> usize

Returns the total number of example records stored in this LogGroup.

§Returns

The number of examples as a usize.

Source

pub fn is_empty(&self) -> bool

Checks if the log group contains any example records.

§Returns

true if the log group has no examples, false otherwise.

Source

pub fn get_examples(&self) -> Vec<&Record>

Returns a vector of references to the example records for this group.

§Returns

A Vec<&Record> containing references to all example records.

Source

pub fn get_id(&self) -> Uuid

Returns the unique identifier (Uuid) associated with this LogGroup.

This ID is typically the same as the Uuid of the Record that created the group.

§Returns

The Uuid of the log group.

Source

pub fn get_time(&self) -> DateTime<Utc>

Returns the creation timestamp of the base event in the LogGroup as a DateTime<Utc>.

This timestamp is derived from the Uuid of the base event.

§Returns

A DateTime<Utc> representing the creation time of the base event.

Trait Implementations§

Source§

impl Clone for LogGroup

Source§

fn clone(&self) -> LogGroup

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 LogGroup

Source§

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

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

impl Display for LogGroup

Source§

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

Formats the LogGroup for display.

This implementation provides a human-readable summary of the log group, including its ID, first seen timestamp, base event, number of examples, and number of wildcards.

§Arguments
  • f - The formatter to write into.
§Returns

A fmt::Result indicating success or failure of the formatting operation.

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more