public TimestampLogParser(ILogger logger, RegexParserOptions options, Encoding encoding, int bufferSize) : base(logger, ConvertTimeStampToRegex(options.TimestampFormat), options, encoding, bufferSize) { }
private static RegexParserOptions ParseRegexOptions(IConfiguration config) { var options = new RegexParserOptions { ExtractionPattern = config["ExtractionPattern"], ExtractionRegexOptions = config["ExtractionRegexOptions"], TimeZoneKind = Utility.ParseTimeZoneKind(config["TimeZoneKind"]), TimestampFormat = config["TimestampFormat"] }; if (bool.TryParse(config["RemoveUnmatched"], out var removeUnmatched) && removeUnmatched) { options.RemoveUnmatchedRecord = true; } return(options); }
public RegexLogParser(ILogger logger, string pattern, RegexParserOptions options, Encoding encoding, int bufferSize) { _patternRegex = new Regex(pattern, RegexOptions.Compiled); if (!string.IsNullOrEmpty(options.ExtractionPattern)) { var regexOptions = ParseRegexOptions(options.ExtractionRegexOptions); _extractionRegex = new Regex(options.ExtractionPattern, regexOptions | RegexOptions.Compiled); } _timestampFormat = options.TimestampFormat; _logger = logger; _timeZoneKind = options.TimeZoneKind; _removeUnmatchedRecord = options.RemoveUnmatchedRecord; _encoding = encoding; _bufferSize = bufferSize; }