private void Add(string line, LevelFlags level, int numberOfLinesRead, DateTime?timestamp) { if (_properties.GetValue(LogFileProperties.StartTimestamp) == null) { _properties.SetValue(LogFileProperties.StartTimestamp, timestamp); } if (timestamp != null) { _properties.SetValue(LogFileProperties.EndTimestamp, timestamp); } var duration = timestamp - _properties.GetValue(LogFileProperties.StartTimestamp); _properties.SetValue(LogFileProperties.Duration, duration); lock (_syncRoot) { int lineIndex = _entries.Count; var logLine = new LogLine(lineIndex, lineIndex, line, level, timestamp); var translated = Translate(logLine); _entries.Add(translated); _maxCharactersPerLine = Math.Max(_maxCharactersPerLine, translated.Message?.Length ?? 0); if (timestamp != null) { UpdateLastModifiedIfNecessary(timestamp.Value); } } Listeners.OnRead(numberOfLinesRead); }
public void TestGetLogLevelEmptyBySection([Range(from: 0, to: 2)] int count, [Range(from: 0, to: 2)] int offset, [Range(from: 0, to: 2)] int surplus) { var logFile = CreateEmpty(); var buffer = new LevelFlags[offset + count + surplus]; for (int i = 0; i < offset + count + surplus; ++i) { buffer[i] = LevelFlags.Fatal; } logFile.GetColumn(new LogFileSection(0, count), LogFileColumns.LogLevel, buffer, offset); for (int i = 0; i < offset; ++i) { buffer[i].Should().Be(LevelFlags.Fatal, "because we've specified an offset and thus values before that offset shouldn't have been touched"); } for (int i = 0; i < count; ++i) { buffer[offset + i].Should().Be(LevelFlags.None, "because we've accessed a region which is out of range and therefore the default value should've been copied to the buffer"); } for (int i = offset + count; i < offset + count + surplus; ++i) { buffer[i].Should().Be(LevelFlags.Fatal, "because we've specified a count and thus values after shouldn't have been touched"); } }
public void TestCopyFromArray_PartiallyFilled() { var entries = new LogBufferList(Core.Columns.LogLevel); entries.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object> { { Core.Columns.LogLevel, LevelFlags.Info } })); entries.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object> { { Core.Columns.LogLevel, LevelFlags.Trace } })); var buffer = new LevelFlags[] { LevelFlags.All, LevelFlags.Debug, LevelFlags.Error, LevelFlags.Warning }; entries.Resize(4); entries.Count.Should().Be(buffer.Length); entries.CopyFrom(Core.Columns.LogLevel, 0, buffer, 0, buffer.Length); entries[0].LogLevel.Should().Be(LevelFlags.All, "because the first entry's level should have been overwritten"); entries[1].LogLevel.Should().Be(LevelFlags.Debug, "because the second entry's level should have been overwritten"); entries[2].LogLevel.Should().Be(LevelFlags.Error, "because the third log entry should been added"); entries[3].LogLevel.Should().Be(LevelFlags.Warning, "because the third log entry should been added"); }
private void SetFlag(LevelFlags flag, bool value) { if (value) levelFlags |= flag; else levelFlags &= ~flag; }
/// <summary> /// Adds a multi line log entry to this log file. /// </summary> /// <param name="level"></param> /// <param name="timestamp"></param> /// <param name="lines"></param> public void AddMultilineEntry(LevelFlags level, DateTime?timestamp, params string[] lines) { lock (_syncRoot) { UpdateTimestampProperties(timestamp); var logEntryIndex = GetLogEntryIndex(timestamp, out var elapsed, out var deltaTime); foreach (var line in lines) { var logEntry = new LogEntry { Index = _logBuffer.Count, OriginalIndex = _logBuffer.Count, LineNumber = _logBuffer.Count + 1, OriginalLineNumber = _logBuffer.Count + 1, LogEntryIndex = logEntryIndex, RawContent = line, LogLevel = level, Timestamp = timestamp, ElapsedTime = elapsed, DeltaTime = deltaTime }; _logBuffer.Add(logEntry); SetValue(Core.Properties.LogEntryCount, _logBuffer.Count); SetValue(TextProperties.MaxCharactersInLine, Math.Max(GetProperty(TextProperties.MaxCharactersInLine), line.Length)); } Touch(); _listeners.OnRead(_logBuffer.Count); } }
public void TestGetLogLevelEmptyByIndices([Range(from: -1, to: 1)] int invalidIndex, [Range(from: 0, to: 2)] int count, [Range(from: 0, to: 2)] int offset, [Range(from: 0, to: 2)] int surplus) { var logFile = CreateEmpty(); var buffer = new LevelFlags[offset + count + surplus]; for (int i = 0; i < offset + count + surplus; ++i) { buffer[i] = LevelFlags.Fatal; } var indices = Enumerable.Range(invalidIndex, count).Select(x => (LogLineIndex)x).ToArray(); logFile.GetColumn(indices, LogFileColumns.LogLevel, buffer, offset); for (int i = 0; i < offset; ++i) { buffer[i].Should().Be(LevelFlags.Fatal, "because we've specified an offset and thus values before that offset shouldn't have been touched"); } for (int i = 0; i < count; ++i) { buffer[offset + i].Should().Be(LevelFlags.None, "because we've accessed a region which is out of range and therefore the default value should've been copied to the buffer"); } for (int i = offset + count; i < offset + count + surplus; ++i) { buffer[i].Should().Be(LevelFlags.Fatal, "because we've specified a count and thus values after shouldn't have been touched"); } }
public ParsedLogEntry(IReadOnlyLogEntry inner, string rawContent, LevelFlags logLevel, DateTime?timestamp) { _inner = inner; _rawContent = rawContent; _logLevel = logLevel; _timestamp = timestamp; }
private void Append(LogFileSection section) { var buffer = new LogLine[section.Count]; _source.GetSection(section, buffer); lock (_syncRoot) { for (var i = 0; i < section.Count; ++i) { var line = buffer[i]; if (_currentLogEntry.EntryIndex.IsInvalid || !AppendToCurrentLogEntry(line)) { _currentLogEntry = _currentLogEntry.NextEntry(line.LineIndex); _currentLogEntryLevel = line.Level; _currentLogEntryTimestamp = line.Timestamp; } _indices.Add(_currentLogEntry); } } _currentSourceIndex += section.Count; _fullSourceSection = new LogFileSection(0, _currentSourceIndex.Value); }
/// <summary> /// /// </summary> /// <param name="rawContent"></param> /// <param name="level"></param> public void AddEntry(string rawContent, LevelFlags level) { var logEntry = new LogEntry2(); logEntry.Add(LogFileColumns.RawContent, rawContent); logEntry.Add(LogFileColumns.LogLevel, level); Add(logEntry); }
public static ILogEntryFilter Create(LevelFlags levelFilter, IEnumerable<ILogEntryFilter> additionalFilters = null) { var filters = new List<ILogEntryFilter> {new LevelFilter(levelFilter)}; if (additionalFilters != null) filters.AddRange(additionalFilters); return Create(filters); }
/// <summary> /// /// </summary> /// <param name="levels"></param> /// <returns></returns> public static ILogEntryFilter Create(LevelFlags levels) { if (levels == LevelFlags.All) { return(null); } return(new LevelFilter(levels)); }
public bool HasFlag(byte[,] chunk, int x, int y, LevelFlags flag) { if (flag == LevelFlags.Empty) { return((chunk[x, y] | flag.ToByte()) == flag.ToByte()); } return((chunk[x, y] & flag.ToByte()) == flag.ToByte()); }
public static ILogEntryFilter Create(string substringFilter, bool ignoreCase, LevelFlags levelFilter, IEnumerable<ILogEntryFilter> additionalFilters = null) { List<ILogEntryFilter> filters = CreateFilters(substringFilter, ignoreCase, levelFilter); if (additionalFilters != null) filters.AddRange(additionalFilters); return Create(filters); }
public void TestCopyFromArray() { var inner = new Mock <ILogBuffer>(); var view = new LogBufferView(inner.Object, Core.Columns.LogLevel, Core.Columns.Message); var source = new LevelFlags[101]; view.CopyFrom(Core.Columns.LogLevel, 42, source, 2, 98); inner.Verify(x => x.CopyFrom(Core.Columns.LogLevel, 42, source, 2, 98), Times.Once); }
public DataSource() { Order = -1; _activatedQuickFilters = new List<Guid>(); LevelFilter = LevelFlags.All; ColorByLevel = true; ShowLineNumbers = true; SelectedLogLines = new HashSet<LogLineIndex>(); VisibleLogLine = LogLineIndex.Invalid; }
/// <summary> /// /// </summary> /// <param name="rawContent"></param> /// <param name="level"></param> /// <returns>A copy of the log entry as it was entered into this log file with all columns of this file (columns not present in the given log entry will be set to their default value).</returns> public IReadOnlyLogEntry AddEntry(string rawContent, LevelFlags level) { var logEntry = new LogEntry { RawContent = rawContent, LogLevel = level }; return(Add(logEntry)); }
public void SetFlag(byte[,] chunk, int x, int y, LevelFlags flag) { if (flag == LevelFlags.Empty) { chunk[x, y] = flag.ToByte(); } else { chunk[x, y] |= flag.ToByte(); } }
public LogLine(int lineIndex, int originalLineIndex, int logEntryIndex, LogLineSourceId sourceId, string message, LevelFlags level, DateTime?timestamp, int matchedFilters) { LineIndex = lineIndex; OriginalLineIndex = originalLineIndex; Message = message; Level = level; LogEntryIndex = logEntryIndex; Timestamp = timestamp; MatchedFilters = matchedFilters; SourceId = sourceId; }
/// <summary> /// /// </summary> /// <param name="rawContent"></param> /// <param name="level"></param> /// <param name="timestamp"></param> /// <returns>A copy of the log entry as it was entered into this log file with all columns of this file (columns not present in the given log entry will be set to their default value).</returns> public IReadOnlyLogEntry AddEntry(string rawContent, LevelFlags level, DateTime?timestamp) { var logEntry = new LogEntry { RawContent = rawContent, LogLevel = level, Timestamp = timestamp }; return(Add(logEntry)); }
public static List<ILogEntryFilter> CreateFilters(string substringFilter, bool ignoreCase, LevelFlags levelFilter) { var filters = new List<ILogEntryFilter>(); if (!string.IsNullOrEmpty(substringFilter)) filters.Add(new SubstringFilter(substringFilter, ignoreCase)); if (levelFilter != LevelFlags.All) filters.Add(new LevelFilter(levelFilter)); return filters; }
private void SetFlag(LevelFlags flag, bool value) { if (value) { levelFlags |= flag; } else { levelFlags &= ~flag; } }
/// <summary> /// Creates a new <see cref="ILogEntryFilter" /> from the given values. /// </summary> /// <param name="substringFilter"></param> /// <param name="ignoreCase"></param> /// <param name="levelFilter"></param> /// <param name="additionalFilters"></param> /// <returns></returns> public static ILogEntryFilter Create(string substringFilter, bool ignoreCase, LevelFlags levelFilter, IEnumerable <ILogEntryFilter> additionalFilters = null) { var filters = CreateFilters(substringFilter, ignoreCase, levelFilter); if (additionalFilters != null) { filters.AddRange(additionalFilters); } return(Create(filters)); }
public DataSource() { Order = -1; _activatedQuickFilters = new List <QuickFilterId>(); LevelFilter = LevelFlags.All; ColorByLevel = true; ShowLineNumbers = true; IsExpanded = true; SelectedLogLines = new HashSet <LogLineIndex>(); VisibleLogLine = LogLineIndex.Invalid; }
private void Add(string line, LevelFlags level, int numberOfLinesRead, DateTime?timestamp) { if (_properties.GetValue(LogFileProperties.StartTimestamp) == null) { _properties.SetValue(LogFileProperties.StartTimestamp, timestamp); } if (timestamp != null) { _properties.SetValue(LogFileProperties.EndTimestamp, timestamp); } lock (_syncRoot) { int lineIndex = _entries.Count; var logLine = new LogLine(lineIndex, lineIndex, line, level, timestamp); var translated = Translate(logLine); _entries.Add(translated); _maxCharactersPerLine = Math.Max(_maxCharactersPerLine, translated.Message?.Length ?? 0); if (timestamp != null) { var lastModified = _properties.GetValue(LogFileProperties.LastModified); var difference = timestamp - lastModified; if (difference >= TimeSpan.FromSeconds(10)) { // I've had this issue occur on one system and I can't really explain it. // For some reason, new FileInfo(...).LastWriteTime will not give correct // results when we can see that the bloody file is being written to as we speak. // As a work around, we'll just use the timestamp of the log file as lastModifed // if that happens to be newer. // // This might be related to files being consumed from a network share. Anyways, // this quick fix should improve user feedback... if (!_loggedTimestampWarning) { Log.InfoFormat( "FileInfo.LastWriteTime results in a time stamp that is less than the parsed timestamp (LastWriteTime={0}, Parsed={1}), using parsed instead", lastModified, timestamp ); _loggedTimestampWarning = true; } _properties.SetValue(LogFileProperties.LastModified, timestamp.Value); } } } Listeners.OnRead(numberOfLinesRead); }
/// <summary> /// Creates a new <see cref="ILogEntryFilter" /> from the given values. /// </summary> /// <param name="levelFilter"></param> /// <param name="andFilters"></param> /// <param name="orFilters"></param> /// <returns></returns> public static ILogEntryFilter Create(LevelFlags levelFilter, IEnumerable <ILogEntryFilter> andFilters, IEnumerable <ILogEntryFilter> orFilters = null) { var filters = new List <ILogEntryFilter> { Create(levelFilter) }; if (andFilters != null) { filters.AddRange(andFilters); } return(Create(filters)); }
/////////////////////////////////////////////////////////////////////// public static bool HasFlags( LevelFlags flags, LevelFlags hasFlags, bool all ) { if (all) { return((flags & hasFlags) == hasFlags); } else { return((flags & hasFlags) != LevelFlags.None); } }
/// <summary> /// Creates a new <see cref="ILogEntryFilter" /> from the given values. /// </summary> /// <param name="substringFilter"></param> /// <param name="ignoreCase"></param> /// <param name="levelFilter"></param> /// <returns></returns> public static List <ILogEntryFilter> CreateFilters(string substringFilter, bool ignoreCase, LevelFlags levelFilter) { var filters = new List <ILogEntryFilter>(); if (!string.IsNullOrEmpty(substringFilter)) { filters.Add(new SubstringFilter(substringFilter, ignoreCase)); } if (levelFilter != LevelFlags.All) { filters.Add(new LevelFilter(levelFilter)); } return(filters); }
/// <summary> /// Adds a multi line log entry to this log file. /// </summary> /// <param name="level"></param> /// <param name="timestamp"></param> /// <param name="lines"></param> public void AddMultilineEntry(LevelFlags level, DateTime?timestamp, params string[] lines) { lock (_syncRoot) { LogEntryIndex logEntryIndex; TimeSpan? elapsed, deltaTime; if (_logEntries.Count > 0) { var first = _logEntries[0]; var last = _logEntries[_logEntries.Count - 1]; logEntryIndex = last.LogEntryIndex + 1; elapsed = timestamp - first.Timestamp; deltaTime = timestamp - last.Timestamp; } else { logEntryIndex = 0; elapsed = null; deltaTime = null; _properties.SetValue(LogFileProperties.StartTimestamp, timestamp); } _properties.SetValue(LogFileProperties.EndTimestamp, timestamp); foreach (var line in lines) { var logEntry = new LogEntry2(); logEntry.Add(LogFileColumns.Index, _logEntries.Count); logEntry.Add(LogFileColumns.OriginalIndex, _logEntries.Count); logEntry.Add(LogFileColumns.LineNumber, _logEntries.Count + 1); logEntry.Add(LogFileColumns.OriginalLineNumber, _logEntries.Count + 1); logEntry.Add(LogFileColumns.LogEntryIndex, logEntryIndex); logEntry.Add(LogFileColumns.RawContent, line); logEntry.Add(LogFileColumns.LogLevel, level); logEntry.Add(LogFileColumns.Timestamp, timestamp); logEntry.Add(LogFileColumns.ElapsedTime, elapsed); logEntry.Add(LogFileColumns.DeltaTime, deltaTime); _logEntries.Add(logEntry); MaxCharactersPerLine = Math.Max(MaxCharactersPerLine, line.Length); } Touch(); _listeners.OnRead(_logEntries.Count); } }
private void OnTraceChanged(bool isChecked) { if (DataSource == null) { return; } const LevelFlags level = LevelFlags.Trace; if (isChecked) { DataSource.LevelsFilter |= level; } else { DataSource.LevelsFilter &= ~level; } }
public LogFile(ITaskScheduler scheduler, string fileName) : base(scheduler) { if (fileName == null) throw new ArgumentNullException("fileName"); _fileName = fileName; _fullFilename = fileName; if (!Path.IsPathRooted(_fullFilename)) _fullFilename = Path.Combine(Directory.GetCurrentDirectory(), fileName); _entries = new List<LogLine>(); _syncRoot = new object(); _previousLevel = LevelFlags.None; _levels = new List<KeyValuePair<int, LevelFlags>>(); StartTask(); }
private void CreateFilteredLogFile() { _filteredLogFile?.Dispose(); LevelFlags levelFilter = LevelFilter; ILogLineFilter logLineFilter = CreateLogLineFilter(); ILogEntryFilter logEntryFilter = Filter.Create(levelFilter, _quickFilterChain); if (Filter.IsFilter(logEntryFilter) || Filter.IsFilter(logLineFilter)) { _filteredLogFile = UnfilteredLogFile.AsFiltered(_taskScheduler, logLineFilter, logEntryFilter, _maximumWaitTime); _logFile.InnerLogFile = _filteredLogFile; } else { _filteredLogFile = null; _logFile.InnerLogFile = UnfilteredLogFile; } }
private void CreateFilteredLogFile() { _filteredLogFile?.Dispose(); LevelFlags levelFilter = LevelFilter; ILogLineFilter logLineFilter = HideEmptyLines ? (ILogLineFilter) new EmptyLogLineFilter() : new NoFilter(); ILogEntryFilter logEntryFilter = Filter.Create(levelFilter, _quickFilterChain); if (logEntryFilter != null) { _filteredLogFile = UnfilteredLogFile.AsFiltered(_taskScheduler, logLineFilter, logEntryFilter, _maximumWaitTime); _logFile.InnerLogFile = _filteredLogFile; } else { _filteredLogFile = null; _logFile.InnerLogFile = UnfilteredLogFile; } }
public void TestCopyFromArray_Empty() { var entries = new LogBufferList(Core.Columns.LogLevel); var buffer = new LevelFlags[] { LevelFlags.All, LevelFlags.Debug, LevelFlags.Error, LevelFlags.Warning }; entries.Resize(4); entries.Count.Should().Be(buffer.Length); entries.CopyFrom(Core.Columns.LogLevel, 0, buffer, 0, buffer.Length); entries[0].LogLevel.Should().Be(LevelFlags.All); entries[1].LogLevel.Should().Be(LevelFlags.Debug); entries[2].LogLevel.Should().Be(LevelFlags.Error); entries[3].LogLevel.Should().Be(LevelFlags.Warning); }
public void TestCopyFromArray_PartiallyOutOfBounds2() { var entries = new LogBufferList(Core.Columns.LogLevel); entries.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object> { { Core.Columns.LogLevel, LevelFlags.Info } })); entries.Add(new ReadOnlyLogEntry(new Dictionary <IColumnDescriptor, object> { { Core.Columns.LogLevel, LevelFlags.Trace } })); var buffer = new LevelFlags[] { LevelFlags.All, LevelFlags.Debug }; new Action(() => entries.CopyFrom(Core.Columns.LogLevel, -1, buffer, 0, buffer.Length)) .Should().Throw <ArgumentOutOfRangeException>(); entries[0].LogLevel.Should().Be(LevelFlags.Info, "because the first entry's level should have been overwritten"); entries[1].LogLevel.Should().Be(LevelFlags.Trace, "because the second entry's level should have been overwritten"); }
public void TestLevelFilter1([ValueSource(nameof(NotAll))] LevelFlags flags) { var dataSource = new Mock <IFileDataSource>(); var logFile = new Mock <ILogSource>(); logFile.Setup(x => x.GetProperty(Properties.EmptyReason)).Returns((IEmptyReason)null); logFile.Setup(x => x.GetProperty(Properties.LogEntryCount)).Returns(1); logFile.Setup(x => x.GetProperty(Properties.Size)).Returns(Size.FromBytes(1)); var filteredLogFile = new Mock <ILogSource>(); dataSource.Setup(x => x.UnfilteredLogSource).Returns(logFile.Object); dataSource.Setup(x => x.FilteredLogSource).Returns(filteredLogFile.Object); dataSource.Setup(x => x.LevelFilter).Returns(flags); dataSource.Setup(x => x.Search).Returns(new Mock <ILogSourceSearch>().Object); var dataSourceModel = CreateFileViewModel(dataSource.Object); var model = new LogViewerViewModel(dataSourceModel, _actionCenter.Object, _settings.Object, TimeSpan.Zero); model.LogEntryCount.Should().Be(0); model.NoEntriesExplanation.Should().Be("Nothing matches level filter"); model.NoEntriesAction.Should().Be("Try filtering by different levels or display everything regardless of its level again"); }
public void TestLevelFilter1([ValueSource(nameof(NotAll))] LevelFlags flags) { var dataSource = new Mock <ISingleDataSource>(); var logFile = new Mock <ILogFile>(); logFile.Setup(x => x.GetValue(LogFileProperties.EmptyReason)).Returns(ErrorFlags.None); logFile.Setup(x => x.Count).Returns(1); logFile.Setup(x => x.GetValue(LogFileProperties.Size)).Returns(Size.FromBytes(1)); var filteredLogFile = new Mock <ILogFile>(); dataSource.Setup(x => x.UnfilteredLogFile).Returns(logFile.Object); dataSource.Setup(x => x.FilteredLogFile).Returns(filteredLogFile.Object); dataSource.Setup(x => x.LevelFilter).Returns(flags); dataSource.Setup(x => x.Search).Returns(new Mock <ILogFileSearch>().Object); var dataSourceModel = new SingleDataSourceViewModel(dataSource.Object, _actionCenter.Object); var model = new LogViewerViewModel(dataSourceModel, _actionCenter.Object, _settings.Object, TimeSpan.Zero); model.LogEntryCount.Should().Be(0); model.NoEntriesExplanation.Should().Be("Not a single log entry matches the level selection"); model.NoEntriesSubtext.Should().BeNull(); }
protected override TimeSpan RunOnce(CancellationToken token) { try { if (!File.Exists(_fileName)) { OnReset(null, out _numberOfLinesRead, out _lastPosition); _exists = false; _fileSize = null; SetEndOfSourceReached(); } else { using (var stream = new FileStream(_fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var reader = new StreamReader(stream)) { _exists = true; var info = new FileInfo(_fileName); _lastModified = info.LastWriteTime; _fileSize = info.Length; if (stream.Length >= _lastPosition) { stream.Position = _lastPosition; } else { OnReset(stream, out _numberOfLinesRead, out _lastPosition); } string line; while ((line = reader.ReadLine()) != null) { token.ThrowIfCancellationRequested(); ResetEndOfSourceReached(); ++_numberOfLinesRead; LevelFlags level = DetermineLevel(line, _levels); DateTime? timestamp; int logEntryIndex; if (level != LevelFlags.None) { timestamp = ParseTimestamp(line); logEntryIndex = _nextLogEntryIndex; ++_nextLogEntryIndex; } else { if (_nextLogEntryIndex > 0) { logEntryIndex = _nextLogEntryIndex - 1; } else { logEntryIndex = 0; } // This line belongs to the previous line and together they form // (part of) a log entry. Even though only a single line mentions // the log level, all lines are given the same log level. level = _previousLevel; timestamp = _previousTimestamp; } Add(line, level, _numberOfLinesRead, logEntryIndex, timestamp); _previousLevel = level; _previousTimestamp = timestamp; } _lastPosition = stream.Position; } Listeners.OnRead(_numberOfLinesRead); SetEndOfSourceReached(); } } catch (FileNotFoundException e) { Log.Debug(e); } catch (DirectoryNotFoundException e) { Log.Debug(e); } catch (OperationCanceledException e) { Log.Debug(e); } catch (Exception e) { Log.Debug(e); } return TimeSpan.FromMilliseconds(100); }
private void Add(string line, LevelFlags level, int numberOfLinesRead, int numberOfLogEntriesRead, DateTime? timestamp) { if (_startTimestamp == null) _startTimestamp = timestamp; lock (_syncRoot) { int lineIndex = _entries.Count; var logLine = new LogLine(lineIndex, numberOfLogEntriesRead, line, level, timestamp); _entries.Add(logLine); _maxCharactersPerLine = Math.Max(_maxCharactersPerLine, line.Length); } Listeners.OnRead(numberOfLinesRead); }
private bool GetFlag(LevelFlags flag) { return (levelFlags & flag) != 0; }
public LevelFilter(LevelFlags level) { Level = level; }
public void Restore(XmlReader reader, out bool neededPatching) { int count = reader.AttributeCount; for (int i = 0; i < count; ++i) { reader.MoveToAttribute(i); switch (reader.Name) { case "file": File = reader.Value; break; case "followtail": FollowTail = reader.ReadContentAsBool(); break; case "showlinenumbers": ShowLineNumbers = reader.ReadContentAsBool(); break; case "stringfilter": case "searchterm": SearchTerm = reader.Value; break; case "levelfilter": LevelFilter = reader.ReadContentAsEnum<LevelFlags>(); break; case "colorbylevel": ColorByLevel = reader.ReadContentAsBool(); break; case "visibleentryindex": VisibleLogLine = reader.ReadContentAsInt(); break; case "id": Id = reader.ReadContentAsGuid(); break; case "parentid": ParentId = reader.ReadContentAsGuid(); break; case "lastviewed": LastViewed = reader.ReadContentAsDateTime2(); break; case "horizontaloffset": HorizontalOffset = reader.ReadContentAsDouble2(); break; } } if (Id == Guid.Empty) { Id = Guid.NewGuid(); Log.InfoFormat("Data Source '{0}' doesn't have an ID yet, setting it to: {1}", File, Id ); neededPatching = true; } else { neededPatching = false; } reader.MoveToContent(); XmlReader subtree = reader.ReadSubtree(); while (subtree.Read()) { switch (subtree.Name) { case "activatedquickfilters": IEnumerable<Guid> filters = ReadActivatedQuickFilters(reader); ActivatedQuickFilters.Clear(); ActivatedQuickFilters.AddRange(filters); break; } } }
public static ILogEntryFilter Create(string substringFilter, LevelFlags levelFilter) { return Create(CreateFilters(substringFilter, true, levelFilter)); }