Beispiel #1
0
        static (IDictionary <string, object>, string) ExtractValues(string pattern, string candidate)
        {
            var parsed    = ExtractionPatternParser.Parse(pattern);
            var extractor = ExtractionPatternInterpreter.CreateNameValueExtractor(parsed);

            return(extractor.ExtractValues(candidate));
        }
        public PlainTextLogEventReader(TextReader input, string extractionPattern)
        {
            if (extractionPattern == null)
            {
                throw new ArgumentNullException(nameof(extractionPattern));
            }
            _nameValueExtractor = ExtractionPatternInterpreter.CreateNameValueExtractor(ExtractionPatternParser.Parse(extractionPattern));

            _reader = new FrameReader(input, SpanEx.MatchedBy(_nameValueExtractor.StartMarker), TrailingLineArrivalDeadline);
        }
Beispiel #3
0
        public void TheTrailingIndentPatternDoesNotMatchLinesStartingWithWhitespace()
        {
            var multilineMessageExtractor =
                ExtractionPatternInterpreter.CreateNameValueExtractor(
                    ExtractionPatternParser.Parse("{@m:trailingindent}"));
            var frame = " world";

            var(properties, remainder) = multilineMessageExtractor.ExtractValues(frame);
            Assert.Empty(properties);
            Assert.Equal(frame, remainder);
        }
Beispiel #4
0
        public void TheTrailingIndentPatternMatchesMultilineMessages()
        {
            var multilineMessageExtractor =
                ExtractionPatternInterpreter.CreateNameValueExtractor(
                    ExtractionPatternParser.Parse("{@m:trailingindent}"));
            var frame = $"Hello,{Environment.NewLine} world!";

            var(properties, remainder) = multilineMessageExtractor.ExtractValues(frame);
            Assert.Null(remainder);
            Assert.Single(properties, p => p.Key == ReifiedProperties.Message &&
                          ((TextSpan)p.Value).ToStringValue() == frame);
        }