コード例 #1
0
        /// <inheritdoc />
        public List <LogLineMatch> Match(IReadOnlyLogEntry line)
        {
            var matches = new List <LogLineMatch>();

            Match(line, matches);
            return(matches);
        }
コード例 #2
0
 public ParsedLogEntry(IReadOnlyLogEntry inner, string rawContent, LevelFlags logLevel, DateTime?timestamp)
 {
     _inner      = inner;
     _rawContent = rawContent;
     _logLevel   = logLevel;
     _timestamp  = timestamp;
 }
コード例 #3
0
ファイル: LogEntryCache.cs プロジェクト: tank0226/Tailviewer
        public void Add(IReadOnlyLogEntry logEntry)
        {
            var bufferIndex = _buffer.Count;

            _buffer.Add(logEntry);
            _bufferIndexByLineIndex[logEntry.Index] = bufferIndex;
        }
コード例 #4
0
        /// <inheritdoc />
        public List <LogLineMatch> Match(IReadOnlyLogEntry line)
        {
            var ret = new List <LogLineMatch>();

            Match(line, ret);
            return(ret);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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;
        }
コード例 #7
0
ファイル: AndFilter.cs プロジェクト: tank0226/Tailviewer
 /// <inheritdoc />
 public void Match(IReadOnlyLogEntry line, List <LogLineMatch> matches)
 {
     foreach (var filter in _filters)
     {
         filter.Match(line, matches);
     }
 }
コード例 #8
0
ファイル: InvertFilter.cs プロジェクト: tank0226/Tailviewer
 /// <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>());
 }
コード例 #9
0
 /// <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);
     }
 }
コード例 #10
0
 public TextLine(IReadOnlyLogEntry logEntry,
                 HashSet <LogLineIndex> hoveredIndices,
                 HashSet <LogLineIndex> selectedIndices,
                 bool colorByLevel)
     : this(logEntry, hoveredIndices, selectedIndices, colorByLevel, TextSettings.Default,
            new TextBrushes(null))
 {
 }
コード例 #11
0
ファイル: LogBufferList.cs プロジェクト: tank0226/Tailviewer
 /// <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;
 }
コード例 #12
0
ファイル: LogBufferList.cs プロジェクト: tank0226/Tailviewer
 /// <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;
 }
コード例 #13
0
ファイル: LogEntryList.cs プロジェクト: tr00p3r/Tailviewer
            public void Add(IReadOnlyLogEntry logEntry)
            {
                T value;

                _data.Add(logEntry.TryGetValue(_column, out value)
                                        ? value
                                        : _column.DefaultValue);
            }
コード例 #14
0
ファイル: InMemoryLogFile.cs プロジェクト: tr00p3r/Tailviewer
 private LogLine CreateLogLine(IReadOnlyLogEntry logEntry)
 {
     return(new LogLine((int)logEntry.Index,
                        (int)logEntry.OriginalIndex,
                        (int)logEntry.LogEntryIndex,
                        logEntry.RawContent,
                        logEntry.LogLevel,
                        logEntry.Timestamp));
 }
コード例 #15
0
        /// <inheritdoc />
        public virtual void CopyFrom(IReadOnlyLogEntry logEntry)
        {
            var overlappingColumns = logEntry.Columns.Intersect(Columns);

            foreach (var column in overlappingColumns)
            {
                SetValue(column, logEntry.GetValue(column));
            }
        }
コード例 #16
0
        public IReadOnlyLogEntry Parse(IReadOnlyLogEntry logEntry)
        {
            if (!TryParse(logEntry.Index, logEntry.RawContent, out var parsedLogEntry))
            {
                return(logEntry);
            }

            return(parsedLogEntry);
        }
コード例 #17
0
        /// <inheritdoc />
        public bool PassesFilter(IReadOnlyLogEntry logLine)
        {
            if (_regex.IsMatch(logLine.RawContent))
            {
                return(true);
            }

            return(false);
        }
コード例 #18
0
        /// <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]));
            }
        }
コード例 #19
0
ファイル: LogBufferArray.cs プロジェクト: tank0226/Tailviewer
 public override void CopyFrom(IReadOnlyLogEntry logEntry)
 {
     foreach (var column in logEntry.Columns)
     {
         if (_array._dataByColumn.TryGetValue(column, out var columnData))
         {
             columnData.CopyFrom(_index, logEntry);
         }
     }
 }
コード例 #20
0
 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);
     }
 }
コード例 #21
0
        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);
        }
コード例 #22
0
 /// <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);
 }
コード例 #23
0
 public IReadOnlyLogEntry Parse(IReadOnlyLogEntry logEntry)
 {
     try
     {
         return(_inner.Parse(logEntry));
     }
     catch (Exception e)
     {
         Log.ErrorFormat("Caught unexpected exception: {0}", e);
         return(logEntry);
     }
 }
コード例 #24
0
 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);
 }
コード例 #25
0
        /// <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);
        }
コード例 #26
0
ファイル: LevelFilter.cs プロジェクト: tank0226/Tailviewer
        /// <inheritdoc />
        public bool PassesFilter(IReadOnlyLogEntry logLine)
        {
            if ((logLine.LogLevel & _level) != 0)
            {
                return(true);
            }

            if (logLine.LogLevel != LevelFlags.None)
            {
                return(false);
            }

            return(true);
        }
コード例 #27
0
        /// <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);
        }
コード例 #28
0
        /// <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));
        }
コード例 #29
0
ファイル: AndFilter.cs プロジェクト: tank0226/Tailviewer
        /// <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);
        }
コード例 #30
0
        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);
        }