Beispiel #1
0
 /// <inheritdoc />
 public object GetValue(IReadOnlyPropertyDescriptor property)
 {
     lock (_syncRoot)
     {
         return(_storage.GetValue(property));
     }
 }
Beispiel #2
0
        private void SynchronizeProperties()
        {
            _source.GetAllProperties(_propertiesBufferView);

            var sourceProcessed = _propertiesBuffer.GetValue(Core.Properties.PercentageProcessed);
            var sourceCount     = _propertiesBuffer.GetValue(Core.Properties.LogEntryCount);
            var ownProgress     = sourceCount > 0
                                ? Percentage.Of(_count, sourceCount).Clamped()
                                : Percentage.HundredPercent;
            var totalProgress = (sourceProcessed * ownProgress).Clamped();

            _propertiesBuffer.SetValue(Core.Properties.PercentageProcessed, totalProgress);
            _propertiesBuffer.SetValue(Core.Properties.LogEntryCount, _count);

            GetOverwrittenProperties(_propertiesBuffer);

            _properties.CopyFrom(_propertiesBuffer);
        }
        private LogEntryIndex GetLogEntryIndex(DateTime?timestamp, out TimeSpan?elapsed, out TimeSpan?deltaTime)
        {
            LogEntryIndex logEntryIndex;
            DateTime?     lastTimestamp = null;

            if (_logBuffer.Count > 0)
            {
                var last = _logBuffer[_logBuffer.Count - 1];
                logEntryIndex = last.LogEntryIndex + 1;
                lastTimestamp = last.Timestamp;
            }
            else
            {
                logEntryIndex = 0;
            }

            elapsed   = timestamp - _properties.GetValue(Core.Properties.StartTimestamp);
            deltaTime = timestamp - lastTimestamp;
            return(logEntryIndex);
        }
Beispiel #4
0
        private void UpdateProperties()
        {
            Size?      size                 = null;
            DateTime?  lastModified         = null;
            DateTime?  startTimestamp       = null;
            DateTime?  endTimestamp         = null;
            int        maxCharactersPerLine = 0;
            Percentage processed            = Percentage.HundredPercent;

            for (int n = 0; n < _sources.Count; ++n)
            {
                var source = _sources[n];
                source.GetAllProperties(_propertiesBuffer);

                var sourceSize = _propertiesBuffer.GetValue(Core.Properties.Size);
                if (size == null)
                {
                    size = sourceSize;
                }
                else if (sourceSize != null)
                {
                    size += sourceSize;
                }

                var last = _propertiesBuffer.GetValue(Core.Properties.LastModified);
                if (last != null && (last > lastModified || lastModified == null))
                {
                    lastModified = last;
                }
                var start = _propertiesBuffer.GetValue(Core.Properties.StartTimestamp);
                if (start != null && (start < startTimestamp || startTimestamp == null))
                {
                    startTimestamp = start;
                }
                var end = _propertiesBuffer.GetValue(Core.Properties.EndTimestamp);
                if (end != null && (end > endTimestamp || endTimestamp == null))
                {
                    endTimestamp = end;
                }
                maxCharactersPerLine = Math.Max(maxCharactersPerLine, _propertiesBuffer.GetValue(TextProperties.MaxCharactersInLine));

                var sourceProcessed = _propertiesBuffer.GetValue(Core.Properties.PercentageProcessed);
                processed *= sourceProcessed;
            }

            _propertiesBuffer.SetValue(Core.Properties.LogEntryCount, _index.Count);
            _propertiesBuffer.SetValue(TextProperties.MaxCharactersInLine, maxCharactersPerLine);
            _propertiesBuffer.SetValue(Core.Properties.PercentageProcessed, processed);
            _propertiesBuffer.SetValue(Core.Properties.LastModified, lastModified);
            _propertiesBuffer.SetValue(Core.Properties.Size, size);
            _propertiesBuffer.SetValue(Core.Properties.StartTimestamp, startTimestamp);
            _propertiesBuffer.SetValue(Core.Properties.EndTimestamp, endTimestamp);
            _propertiesBuffer.SetValue(Core.Properties.Duration, endTimestamp - startTimestamp);

            // We want to ensure that we modify all properties at once so that users of this log file don't
            // see an inconsistent state of properties when they retrieve them.
            _properties.CopyFrom(_propertiesBuffer);
        }
        private void Process(LogSourceSection section)
        {
            DateTime?startTime    = _propertiesBuffer.GetValue(Core.Properties.StartTimestamp);
            DateTime?endTime      = _propertiesBuffer.GetValue(Core.Properties.EndTimestamp);
            int      traceCount   = _propertiesBuffer.GetValue(Core.Properties.TraceLogEntryCount);
            int      debugCount   = _propertiesBuffer.GetValue(Core.Properties.DebugLogEntryCount);
            int      infoCount    = _propertiesBuffer.GetValue(Core.Properties.InfoLogEntryCount);
            int      warningCount = _propertiesBuffer.GetValue(Core.Properties.WarningLogEntryCount);
            int      errorCount   = _propertiesBuffer.GetValue(Core.Properties.ErrorLogEntryCount);
            int      fatalCount   = _propertiesBuffer.GetValue(Core.Properties.FatalLogEntryCount);
            int      otherCount   = _propertiesBuffer.GetValue(Core.Properties.OtherLogEntryCount);

            _source.GetEntries(section, _buffer, 0, LogSourceQueryOptions.Default);
            bool evaluateTimestamp = _requiredColumns.Contains(Core.Columns.Timestamp);
            bool evaluateLevel     = _requiredColumns.Contains(Core.Columns.LogLevel);

            foreach (var entry in _buffer)
            {
                if (!entry.Index.IsValid)
                {
                    break;
                }

                if (evaluateTimestamp)
                {
                    var timestamp = entry.Timestamp;
                    if (timestamp != null)
                    {
                        if (startTime == null)
                        {
                            startTime = timestamp;
                        }
                        else if (timestamp < startTime)
                        {
                            startTime = timestamp;
                        }

                        if (endTime == null)
                        {
                            endTime = timestamp;
                        }
                        else if (timestamp > endTime)
                        {
                            endTime = timestamp;
                        }
                    }
                }

                if (evaluateLevel)
                {
                    var level = entry.LogLevel;
                    switch (level)
                    {
                    case LevelFlags.Fatal:
                        ++fatalCount;
                        break;

                    case LevelFlags.Error:
                        ++errorCount;
                        break;

                    case LevelFlags.Warning:
                        ++warningCount;
                        break;

                    case LevelFlags.Info:
                        ++infoCount;
                        break;

                    case LevelFlags.Debug:
                        ++debugCount;
                        break;

                    case LevelFlags.Trace:
                        ++traceCount;
                        break;

                    case LevelFlags.Other:
                        ++otherCount;
                        break;
                    }
                }
            }

            if (evaluateTimestamp)
            {
                _propertiesBuffer.SetValue(Core.Properties.StartTimestamp, startTime);
                _propertiesBuffer.SetValue(Core.Properties.EndTimestamp, endTime);
                _propertiesBuffer.SetValue(Core.Properties.Duration, endTime - startTime);
            }

            if (evaluateLevel)
            {
                _propertiesBuffer.SetValue(Core.Properties.TraceLogEntryCount, traceCount);
                _propertiesBuffer.SetValue(Core.Properties.DebugLogEntryCount, debugCount);
                _propertiesBuffer.SetValue(Core.Properties.InfoLogEntryCount, infoCount);
                _propertiesBuffer.SetValue(Core.Properties.WarningLogEntryCount, warningCount);
                _propertiesBuffer.SetValue(Core.Properties.ErrorLogEntryCount, errorCount);
                _propertiesBuffer.SetValue(Core.Properties.FatalLogEntryCount, fatalCount);
                _propertiesBuffer.SetValue(Core.Properties.OtherLogEntryCount, otherCount);
            }
        }