Esempio n. 1
1
 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;
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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()));
        }