pub struct LogContextConfig {
pub keywords: Vec<String>,
pub context_lines: usize,
pub max_matches: usize,
pub case_sensitive: bool,
}Expand description
Configuration for extract_context.
Built with a fluent API; all setters consume and return Self.
§Example
use sanitize_engine::log_context::LogContextConfig;
let config = LogContextConfig::new()
.with_extra_keywords(["timeout", "oomkilled"])
.with_context_lines(15)
.with_max_matches(100);Fields§
§keywords: Vec<String>Keywords to scan for. Each is matched as a substring of the line.
context_lines: usizeLines of context captured before and after each match.
max_matches: usizeMaximum number of matches to return before setting
LogContextResult::truncated.
case_sensitive: boolWhen true, keyword matching is case-sensitive. Default: false.
Implementations§
Source§impl LogContextConfig
impl LogContextConfig
Sourcepub fn with_extra_keywords(
self,
extra: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn with_extra_keywords( self, extra: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Merge additional keywords into the existing list without replacing defaults.
Sourcepub fn with_keywords(
self,
keywords: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn with_keywords( self, keywords: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Replace all keywords with the given list.
Sourcepub fn with_context_lines(self, n: usize) -> Self
pub fn with_context_lines(self, n: usize) -> Self
Set how many lines of context to capture around each match.
Sourcepub fn with_max_matches(self, n: usize) -> Self
pub fn with_max_matches(self, n: usize) -> Self
Set the maximum number of matches to return.
Sourcepub fn case_sensitive(self, sensitive: bool) -> Self
pub fn case_sensitive(self, sensitive: bool) -> Self
Set case-sensitivity for keyword matching.
Trait Implementations§
Source§impl Clone for LogContextConfig
impl Clone for LogContextConfig
Source§fn clone(&self) -> LogContextConfig
fn clone(&self) -> LogContextConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LogContextConfig
impl Debug for LogContextConfig
Source§impl Default for LogContextConfig
impl Default for LogContextConfig
Source§impl<'de> Deserialize<'de> for LogContextConfig
impl<'de> Deserialize<'de> for LogContextConfig
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for LogContextConfig
impl RefUnwindSafe for LogContextConfig
impl Send for LogContextConfig
impl Sync for LogContextConfig
impl Unpin for LogContextConfig
impl UnsafeUnpin for LogContextConfig
impl UnwindSafe for LogContextConfig
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
Mutably borrows from an owned value. Read more
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>
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 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>
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