Exemple #1
0
        private bool TryAddLogEntry(List <LogLine> logEntry)
        {
            if (_indices.Count > 0 && logEntry.Count > 0 &&
                _indices[_indices.Count - 1] == logEntry[logEntry.Count - 1].LineIndex)
            {
                return(true);
            }

            if (_logEntryFilter.PassesFilter(logEntry))
            {
                lock (_indices)
                {
                    if (logEntry.Count > 0)
                    {
                        foreach (LogLine line in logEntry)
                        {
                            _indices.Add(line.LineIndex);
                            _logEntryIndices[line.LineIndex] = _currentLogEntryIndex;
                            _maxCharactersPerLine            = Math.Max(_maxCharactersPerLine, line.Message?.Length ?? 0);
                        }
                        ++_currentLogEntryIndex;
                    }
                }
                Listeners.OnRead(_indices.Count);
                return(true);
            }

            return(false);
        }
        private bool TryAddLogEntry(IReadOnlyList <IReadOnlyLogEntry> logEntry)
        {
            if (_indices.Count > 0 && logEntry.Count > 0 &&
                _indices[_indices.Count - 1] == logEntry[logEntry.Count - 1].Index)
            {
                return(true);
            }

            if (_logEntryFilter.PassesFilter(logEntry))
            {
                lock (_indices)
                {
                    if (logEntry.Count > 0)
                    {
                        foreach (var line in logEntry)
                        {
                            _indices.Add((int)line.Index);
                            _logEntryIndices[(int)line.Index] = _currentLogEntryIndex;
                            _maxCharactersPerLine             = Math.Max(_maxCharactersPerLine, line.RawContent?.Length ?? 0);
                        }
                        ++_currentLogEntryIndex;
                    }
                }
                Listeners.OnRead(_indices.Count);
                return(true);
            }

            return(false);
        }
Exemple #3
0
        /// <inheritdoc />
        public bool PassesFilter(IEnumerable <LogLine> logEntry)
        {
            var passes = new bool[_filters.Length];

            foreach (LogLine logLine in logEntry)
            {
                for (int i = 0; i < _filters.Length; ++i)
                {
                    ILogEntryFilter filter = _filters[i];
                    if (!passes[i])
                    {
                        passes[i] = filter.PassesFilter(logLine);
                    }
                }
            }

// ReSharper disable LoopCanBeConvertedToQuery
// ReSharper disable ForCanBeConvertedToForeach
            for (int i = 0; i < passes.Length; ++i)
// ReSharper restore ForCanBeConvertedToForeach
// ReSharper restore LoopCanBeConvertedToQuery
            {
                if (!passes[i])
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #4
0
 /// <inheritdoc />
 public bool PassesFilter(IEnumerable <LogLine> logEntry)
 {
     return(!_filter.PassesFilter(logEntry));
 }
Exemple #5
0
 /// <inheritdoc />
 public bool PassesFilter(IEnumerable <IReadOnlyLogEntry> logEntry)
 {
     return(!_filter.PassesFilter(logEntry));
 }