public Priority GetPriority(string fileName, IEnumerable <ILogLine> samples) { Priority result = Priority.NotSupport; TimeFormatDeterminer timeDeterminer = new TimeFormatDeterminer(); int timeStampExistsCount = 0; int bracketsExistsCount = 0; int maxBracketNumbers = 1; foreach (var logline in samples) { string line = logline?.FullLine; if (string.IsNullOrEmpty(line)) { continue; } int bracketNumbers = 1; if (null != timeDeterminer.DetermineDateTimeFormatInfo(line)) { timeStampExistsCount++; } else { timeStampExistsCount--; } string noSpaceLine = line.Replace(" ", string.Empty); if (noSpaceLine.IndexOf('[') >= 0 && noSpaceLine.IndexOf(']') >= 0 && noSpaceLine.IndexOf('[') < noSpaceLine.IndexOf(']')) { bracketNumbers += Regex.Matches(noSpaceLine, @"\]\[").Count; bracketsExistsCount++; } else { bracketsExistsCount--; } maxBracketNumbers = Math.Max(bracketNumbers, maxBracketNumbers); } // Add message _columnCount = maxBracketNumbers + 1; _isTimeExists = timeStampExistsCount > 0; if (_isTimeExists) { _columnCount += 2; } if (maxBracketNumbers > 1) { result = Priority.WellSupport; if (bracketsExistsCount > 0) { result = Priority.PerfectlySupport; } } return(result); }
public Priority GetPriority(string fileName, IEnumerable <ILogLine> samples) { Priority result = Priority.NotSupport; int timeStampCount = 0; foreach (var line in samples) { if (line == null || string.IsNullOrEmpty(line.FullLine)) { continue; } var timeDeterminer = new TimeFormatDeterminer(); if (null != timeDeterminer.DetermineDateTimeFormatInfo(line.FullLine)) { timeStampCount++; } else { timeStampCount--; } } if (timeStampCount > 0) { result = Priority.WellSupport; } return(result); }
public ILogLineColumnizer FindColumnizer(string fileName, LogfileReader logFileReader) { if (logFileReader == null || string.IsNullOrEmpty(fileName)) { return(new DefaultLogfileColumnizer()); } ILogLineColumnizer lineColumnizer = null; var timeDeterminer = new TimeFormatDeterminer(); List <ILogLine> loglines = new List <ILogLine> { // Sampling a few lines to select the correct columnizer logFileReader.GetLogLine(0), logFileReader.GetLogLine(1), logFileReader.GetLogLine(2), logFileReader.GetLogLine(3), logFileReader.GetLogLine(4), logFileReader.GetLogLine(5), logFileReader.GetLogLine(25), logFileReader.GetLogLine(100), logFileReader.GetLogLine(200), logFileReader.GetLogLine(400) }; lineColumnizer = PluginRegistry.GetInstance().RegisteredColumnizers.OrderByDescending(x => x.GetPriority(fileName, loglines)).First(); return(lineColumnizer); }