Exemple #1
0
        private void AppendMatches(LogSourceSection section)
        {
            try
            {
                LogBufferArray lines;
                lock (_syncRoot)
                {
                    lines = _logLinesArray;
                    if (lines == null)
                    {
                        return;
                    }
                }

                // We've instructed the logfile to give us exactly up to
                // _logLinesBuffer.Length amount of entries in the ctor, hence the following
                // is correct:
                _logSource.GetEntries(section, lines);

                bool added = false;
                for (int i = 0; i < section.Count; ++i)
                {
                    var line = lines[i];

                    _filter.Match(line, _matchesBuffer);
                    if (_matchesBuffer.Count > 0)
                    {
                        lock (_syncRoot)
                        {
                            foreach (LogLineMatch logLineMatch in _matchesBuffer)
                            {
                                var match = new LogMatch(line.Index, logLineMatch);
                                _matches.Add(match);
                            }
                        }

                        _matchesBuffer.Clear();
                        added = true;
                    }
                }

                if (added)
                {
                    _listeners.EmitSearchChanged(_matches);
                }
            }
            catch (IndexOutOfRangeException e)
            {
                // This exception is usually thrown when we access a portion of the
                // log file that has already been reset. This means that a reset event is
                // either pending or soon to be. So not doing anything else to handle
                // this exception is fine.
                Log.DebugFormat("Caught exception while searching log file: {0}", e);
            }
        }
        public void Add(LogMatch match)
        {
            List <LogLineMatch> lineMatches;

            if (!_matches.TryGetValue(match.Index, out lineMatches))
            {
                lineMatches = new List <LogLineMatch>();
                _matches.Add(match.Index, lineMatches);
            }
            lineMatches.Add(match.Match);
        }
Exemple #3
0
 public void Add(LogMatch match)
 {
     _matchesByLine.Add(match);
     _matches.Add(match);
 }