pub struct SingleLayer {
pub domain: Vec<Regex>,
pub threshold: Ratio<BigInt>,
/* private fields */
}Fields§
§domain: Vec<Regex>Regular expressions defining the domain patterns to be replaced in log lines.
threshold: Ratio<BigInt>The similarity threshold used to determine if a new log line matches an existing LogGroup.
Implementations§
Source§impl SingleLayer
impl SingleLayer
Sourcepub fn new(domain: Vec<String>) -> Result<Self, Error>
pub fn new(domain: Vec<String>) -> Result<Self, Error>
Creates a new SingleLayer drain instance.
§Arguments
domain- A vector of strings, each representing a regular expression pattern to be used for preprocessing log lines. These patterns are replaced with a wildcard token before further processing.
§Returns
A Result containing the new SingleLayer instance on success, or an
anyhow::Error if any of the provided domain patterns are invalid regular expressions.
Sourcepub fn set_threshold(
&mut self,
numerator: u64,
denominator: u64,
) -> Result<(), Error>
pub fn set_threshold( &mut self, numerator: u64, denominator: u64, ) -> Result<(), Error>
Sets the similarity threshold for the drain.
This threshold determines how similar a new log line must be to an existing
LogGroup’s event template to be considered a match. The similarity is
calculated as a ratio of matching tokens to total tokens.
§Arguments
numerator- The numerator of the similarity ratio.denominator- The denominator of the similarity ratio.
§Returns
Ok(()) on success, or an anyhow::Error if the numerator or denominator
cannot be converted into BigInt.
Sourcepub fn resolve(&self, sym: DefaultSymbol) -> String
pub fn resolve(&self, sym: DefaultSymbol) -> String
Resolves a DefaultSymbol back into its original string representation.
This is a utility method that uses the internal string interner to retrieve the string associated with a given symbol.
§Arguments
sym- TheDefaultSymbolto resolve.
§Returns
A String representation of the symbol.
§Panics
Panics if the symbol cannot be resolved, which should not happen under normal operation as symbols are only created from interned strings.
Trait Implementations§
Source§impl Clone for SingleLayer
impl Clone for SingleLayer
Source§fn clone(&self) -> SingleLayer
fn clone(&self) -> SingleLayer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SingleLayer
impl Debug for SingleLayer
Source§impl Display for SingleLayer
impl Display for SingleLayer
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the SingleLayer drain for display.
This implementation provides a human-readable representation of the drain, including its domain patterns, similarity threshold, and a list of all contained log groups.
§Arguments
f- The formatter to write into.
§Returns
A fmt::Result indicating success or failure of the formatting operation.
Source§impl Drain for SingleLayer
impl Drain for SingleLayer
Source§fn process_line(&mut self, line: String) -> Result<bool, Error>
fn process_line(&mut self, line: String) -> Result<bool, Error>
Processes a single log line, attempting to match it against existing log groups.
If the line is empty, it is ignored. Otherwise, it is converted into a Record.
The method then attempts to find a matching LogGroup based on the record’s
length and first token. If a sufficiently similar LogGroup is found (based on
the threshold), the new record is added as an example to that group. If no
match is found, a new LogGroup is created for the record.
§Arguments
line- The log line string to process.
§Returns
Ok(true)if a newLogGroupwas created.Ok(false)if the line was added to an existingLogGroup.Err(anyhow::Error)if an error occurred during processing.
Auto Trait Implementations§
impl !RefUnwindSafe for SingleLayer
impl !UnwindSafe for SingleLayer
impl Freeze for SingleLayer
impl Send for SingleLayer
impl Sync for SingleLayer
impl Unpin for SingleLayer
impl UnsafeUnpin for SingleLayer
Blanket Implementations§
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§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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