public void TestMatch1()
        {
            var filter  = new SubstringFilter("Foobar", true);
            var matches = new List <LogLineMatch>();

            new Action(() => filter.Match(new LogLine(0, 0, null, LevelFlags.All), matches)).Should().NotThrow();
            matches.Should().BeEmpty();
        }
        public void TestMatch2()
        {
            var filter  = new SubstringFilter("a", true);
            var matches = new List <LogLineMatch>();

            filter.Match(new LogLine(0, 0, "Foobar", LevelFlags.All), matches);
            matches.Count.Should().Be(1);
            matches[0].Index.Should().Be(4);
            matches[0].Count.Should().Be(1);
        }
Beispiel #3
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 TestMatch1()
        {
            var filter  = new SubstringFilter("Foobar", true);
            var matches = new List <LogLineMatch>();

            new Action(() => filter.Match(new LogEntry(Core.Columns.Minimum)
            {
                RawContent = null
            }, matches)).Should().NotThrow();
            matches.Should().BeEmpty();
        }
        public void TestMatch2()
        {
            var filter  = new SubstringFilter("a", true);
            var matches = new List <LogLineMatch>();

            filter.Match(new LogEntry(Core.Columns.Minimum)
            {
                RawContent = "Foobar"
            }, matches);
            matches.Count.Should().Be(1);
            matches[0].Index.Should().Be(4);
            matches[0].Count.Should().Be(1);
        }