pub fn new_with_base_patterns() -> Self {
        let mut grok = grok::Grok::empty();
        let mut compiled_patterns = Vec::new();

        // load base patterns
        for &(name, pattern_definition) in base_patterns() {
            grok.insert_definition(name, pattern_definition);
        }

        // compile base patterns
        for &(pattern_name, _) in base_patterns() {
            // compiled_patterns.push(grok.compile("%{USERNAME}", false).unwrap());
            if is_a_good_pattern(pattern_name) {
                let grok_pattern = format!("%{{{}}}", pattern_name);
                let compiled_pattern = grok
                    .compile(&format!("^{}.?$", grok_pattern), false)
                    .unwrap();
                compiled_patterns.push((pattern_name.to_owned(), grok_pattern, compiled_pattern));
            }
        }

        GrokGenerator {
            grok,
            compiled_patterns,
        }
    }
/// generates a GrokGenerator initialized with the base patterns from the patterns folder
generates a GrokGenerator initialized with the base patterns from the patterns folder
generates a GrokGenerator initialized with the base patterns from the patterns folder
pub fn new_with_base_patterns() -> Self {
        let mut grok = grok::Grok::empty();
        let mut compiled_patterns = Vec::new();
        // load base patterns
        for &(name, pattern_definition) in base_patterns() {
            grok.insert_definition(name, pattern_definition);
        }
        // compile base patterns
        for &(pattern_name, _) in base_patterns() {
            // compiled_patterns.push(grok.compile("%{USERNAME}", false).unwrap());
            if is_a_good_pattern(pattern_name) {
                let grok_pattern = format!("%{{{}}}", pattern_name);
                let compiled_pattern = grok
                    .compile(&format!("^{}.?$", grok_pattern), false)
                    .unwrap();
                compiled_patterns.push((pattern_name.to_owned(), grok_pattern, compiled_pattern));
            }
        }
        GrokGenerator {
            grok,
            compiled_patterns,
        }
    }
pub fn new_with_base_patterns ( ) -> Self { let mut grok = grok :: Grok :: empty ( ) ; let mut compiled_patterns = Vec :: new ( ) ; // load base patterns for & ( name , pattern_definition ) in base_patterns ( ) { grok . insert_definition ( name , pattern_definition ) ; } // compile base patterns for & ( pattern_name , _ ) in base_patterns ( ) { // compiled_patterns.push(grok.compile("%{USERNAME}", false).unwrap()); if is_a_good_pattern ( pattern_name ) { let grok_pattern = format ! ( " " pattern_name ) ; let compiled_pattern = grok . compile ( & format ! ( " " grok_pattern ) , false ) . unwrap ( ) ; compiled_patterns . push ( ( pattern_name . to_owned ( ) , grok_pattern , compiled_pattern ) ) ; } } GrokGenerator { grok , compiled_patterns , } }
generates a GrokGenerator initialized with the base patterns from the patterns folder
generates a GrokGenerator initialized with the base patterns from the patterns folder