/// <inheritdoc /> public List <LogLineMatch> Match(IReadOnlyLogEntry line) { var matches = new List <LogLineMatch>(); Match(line, matches); return(matches); }
public ParsedLogEntry(IReadOnlyLogEntry inner, string rawContent, LevelFlags logLevel, DateTime?timestamp) { _inner = inner; _rawContent = rawContent; _logLevel = logLevel; _timestamp = timestamp; }
public void Add(IReadOnlyLogEntry logEntry) { var bufferIndex = _buffer.Count; _buffer.Add(logEntry); _bufferIndexByLineIndex[logEntry.Index] = bufferIndex; }
/// <inheritdoc /> public List <LogLineMatch> Match(IReadOnlyLogEntry line) { var ret = new List <LogLineMatch>(); Match(line, ret); return(ret); }
public bool TryParse(LogLineIndex index, string rawContent, out IReadOnlyLogEntry logEntry) { if (rawContent == null) { logEntry = null; return(false); } var match = _regex.Match(rawContent); if (!match.Success) { logEntry = null; return(false); } var parsedLogEntry = new LogEntry { Index = index, RawContent = rawContent }; foreach (var matcher in _matchers) { matcher.MatchInto(match, parsedLogEntry); } logEntry = parsedLogEntry; return(true); }
public TextLine(IReadOnlyLogEntry logEntry, HashSet <LogLineIndex> hoveredIndices, HashSet <LogLineIndex> selectedIndices, bool colorByLevel, TextSettings textSettings, TextBrushes textBrushes) { if (logEntry == null) { throw new ArgumentNullException(nameof(logEntry)); } if (hoveredIndices == null) { throw new ArgumentNullException(nameof(hoveredIndices)); } if (selectedIndices == null) { throw new ArgumentNullException(nameof(selectedIndices)); } if (textBrushes == null) { throw new ArgumentNullException(nameof(textBrushes)); } _logEntry = logEntry; _hoveredIndices = hoveredIndices; _selectedIndices = selectedIndices; _segments = new List <TextSegment>(); _colorByLevel = colorByLevel; _textSettings = textSettings; _textBrushes = textBrushes; _isFocused = true; }
/// <inheritdoc /> public void Match(IReadOnlyLogEntry line, List <LogLineMatch> matches) { foreach (var filter in _filters) { filter.Match(line, matches); } }
/// <inheritdoc /> public List <LogLineMatch> Match(IReadOnlyLogEntry line) { // We don't mark any text because we would have to mark ALL text excluding // the actual filter text (since we're the inversion of the inner filter). // This is really not helpful and thus we don't mark any text at all... return(new List <LogLineMatch>()); }
/// <inheritdoc /> public void Match(IReadOnlyLogEntry line, List <LogLineMatch> matches) { // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < _filters.Length; ++i) { _filters[i].Match(line, matches); } }
public TextLine(IReadOnlyLogEntry logEntry, HashSet <LogLineIndex> hoveredIndices, HashSet <LogLineIndex> selectedIndices, bool colorByLevel) : this(logEntry, hoveredIndices, selectedIndices, colorByLevel, TextSettings.Default, new TextBrushes(null)) { }
/// <summary> /// </summary> /// <param name="index"></param> /// <param name="logEntry"></param> public void Insert(int index, IReadOnlyLogEntry logEntry) { foreach (var column in _dataByColumn.Values) { column.Insert(index, logEntry); } ++_count; }
/// <summary> /// Adds the given log entry to this list. /// </summary> /// <remarks> /// The log entry must support the same columns as this list, but they do /// not need to be in the same order. /// </remarks> /// <param name="logEntry"></param> public void Add(IReadOnlyLogEntry logEntry) { foreach (var column in _dataByColumn.Values) { column.Add(logEntry); } ++_count; }
public void Add(IReadOnlyLogEntry logEntry) { T value; _data.Add(logEntry.TryGetValue(_column, out value) ? value : _column.DefaultValue); }
private LogLine CreateLogLine(IReadOnlyLogEntry logEntry) { return(new LogLine((int)logEntry.Index, (int)logEntry.OriginalIndex, (int)logEntry.LogEntryIndex, logEntry.RawContent, logEntry.LogLevel, logEntry.Timestamp)); }
/// <inheritdoc /> public virtual void CopyFrom(IReadOnlyLogEntry logEntry) { var overlappingColumns = logEntry.Columns.Intersect(Columns); foreach (var column in overlappingColumns) { SetValue(column, logEntry.GetValue(column)); } }
public IReadOnlyLogEntry Parse(IReadOnlyLogEntry logEntry) { if (!TryParse(logEntry.Index, logEntry.RawContent, out var parsedLogEntry)) { return(logEntry); } return(parsedLogEntry); }
/// <inheritdoc /> public bool PassesFilter(IReadOnlyLogEntry logLine) { if (_regex.IsMatch(logLine.RawContent)) { return(true); } return(false); }
/// <inheritdoc /> public void Match(IReadOnlyLogEntry line, List <LogLineMatch> matches) { var regexMatches = _regex.Matches(line.RawContent); matches.Capacity += regexMatches.Count; for (var i = 0; i < regexMatches.Count; ++i) { matches.Add(new LogLineMatch(regexMatches[i])); } }
public override void CopyFrom(IReadOnlyLogEntry logEntry) { foreach (var column in logEntry.Columns) { if (_array._dataByColumn.TryGetValue(column, out var columnData)) { columnData.CopyFrom(_index, logEntry); } } }
private void TryAddLogLine(IReadOnlyLogEntry logEntry) { // We have a filter that operates on individual lines (regardless of log entry affiliation). // We therefore have to evaluate each line for itself before we can even begin to consider adding a log // entry. if (_logLineFilter.PassesFilter(logEntry)) { _lastLogBuffer.Add(logEntry); } }
private ILogEntry CreateIndex(IReadOnlyLogEntry logEntry) { int numLines; var width = EstimateWidth(logEntry.RawContent, out numLines); var index = new LogEntry(); index.SetValue(RawContentMaxPresentationWidth, width); index.SetValue(PresentationLineCount, numLines); return(index); }
/// <summary> /// Initializes this object. /// </summary> /// <param name="source"></param> /// <param name="parser"></param> public GenericTextLogSource(ILogSource source, ILogEntryParser parser) { _source = source ?? throw new ArgumentNullException(nameof(source)); _parser = parser; _parsedColumns = _parser.Columns.ToList(); _allColumns = _source.Columns.Concat(_parsedColumns).Distinct().ToList(); _listeners = new ProxyLogListenerCollection(source, this); _nothingParsed = new ReadOnlyLogEntry(_parsedColumns); }
public IReadOnlyLogEntry Parse(IReadOnlyLogEntry logEntry) { try { return(_inner.Parse(logEntry)); } catch (Exception e) { Log.ErrorFormat("Caught unexpected exception: {0}", e); return(logEntry); } }
private bool AppendToCurrentLogEntry(IReadOnlyLogEntry logLine) { if (logLine.Timestamp != null) { return(false); //< A line with a timestamp is never added to a previous log entry } if (logLine.LogLevel != LevelFlags.None && logLine.LogLevel != LevelFlags.Other) { return(false); //< A line with a log level is never added to a previous log entry } return(true); }
/// <inheritdoc /> public bool PassesFilter(IReadOnlyLogEntry logLine) { // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < _filters.Length; ++i) { if (_filters[i].PassesFilter(logLine)) { return(true); } } return(false); }
/// <inheritdoc /> public bool PassesFilter(IReadOnlyLogEntry logLine) { if ((logLine.LogLevel & _level) != 0) { return(true); } if (logLine.LogLevel != LevelFlags.None) { return(false); } return(true); }
/// <summary> /// This method is called for every log entry of the source log file /// and we want to detect our custom log levels which aren't natively detected by Tailviewer. /// </summary> /// <remarks> /// This method is called in an unspecified order. This means that Tailviewer is not obligated to linearly /// scan a log file and feed this class each log entry successively. It may do so at times, but if you /// rely on this then your plugin will break with future Tailviewer versions. IF you need to rely on the order /// of log entries given to you, then you should implement <see cref="ILogSourceParserPlugin"/> instead. /// </remarks> /// <param name="logEntry"></param> /// <returns></returns> public IReadOnlyLogEntry Parse(IReadOnlyLogEntry logEntry) { var parsedLogEntry = new LogEntry(logEntry); // We do this by inspecting the "RawContent" field of the original log entry // which is, for text log files, the raw string of the log line without line endings, // and then match our strings to log levels that Tailviewer understands. var logLevel = GetLogLevel(logEntry.RawContent); // Finally, we assign the log level to the parsed log entry parsedLogEntry.LogLevel = logLevel; // which we then return back to Tailviewer. return(parsedLogEntry); }
/// <inheritdoc /> public IReadOnlyLogEntry Parse(IReadOnlyLogEntry logEntry) { var rawContent = logEntry.RawContent; if (string.IsNullOrEmpty(rawContent)) { return(null); } var line = RemoveGarbage(rawContent); var level = _logLevelParser.DetermineLevelFromLine(line); var timestamp = ParseTimestamp(line); return(new ParsedLogEntry(logEntry, line, level, timestamp)); }
/// <inheritdoc /> public bool PassesFilter(IReadOnlyLogEntry logLine) { // ReSharper disable LoopCanBeConvertedToQuery // ReSharper disable ForCanBeConvertedToForeach for (int i = 0; i < _filters.Length; ++i) // ReSharper restore ForCanBeConvertedToForeach // ReSharper restore LoopCanBeConvertedToQuery { if (!_filters[i].PassesFilter(logLine)) { return(false); } } return(true); }
public bool PassesFilter(IReadOnlyLogEntry logLine) { var rawContent = logLine.RawContent; if (rawContent == null) { return(false); } int idx = rawContent.IndexOf(_stringFilter, _comparison); if (idx == -1) { return(false); } return(true); }