public Match(string text, int offset, Grok grok, Regex regexp, System.Text.RegularExpressions.Match match) { Text = text; Offset = offset; Grok = grok; _regexp = regexp; _match = match; }
public void Compile(string pattern) { var grok = new Grok(); foreach(var p in _patterns) grok.AddPattern(p.Key, p.Value); grok.Compile(pattern); Log.InfoFormat("Pile compiled new grok, pattern: {0}, expandedPattern = {1}", pattern, grok.ExpandedPattern); _groks.Add(grok); }
public void Blah() { var grok = new Grok(); grok.AddPattern("USERNAME", "[a-z]+"); grok.AddPattern("HENLOG", "%{USERNAME:user};"); grok.Compile("%{HENLOG:mylog}"); var match = grok.Match("aaaaa;"); match.Should().NotBeNull(); var captures = match.Captures; }
public void Compile(string pattern) { var grok = new Grok(); foreach (var p in _patterns) { grok.AddPattern(p.Key, p.Value); } grok.Compile(pattern); Log.InfoFormat("Pile compiled new grok, pattern: {0}, expandedPattern = {1}", pattern, grok.ExpandedPattern); _groks.Add(grok); }
private Capture GetCapture(string key, IEnumerable <Group> groups) { var patternName = key = Grok.GetCaptureName(key) ?? key; string identifier = null; var splits = key.Split(new[] { ':' }, 2); if (splits.Length > 1) { patternName = splits[0]; identifier = splits[1].Trim(); } return(new Capture(patternName, identifier, groups.Where(g => g.Success).Select(g => g.Value).ToArray())); }