Ejemplo n.º 1
0
        /// <summary>
        ///     Initializes this object.
        /// </summary>
        /// <remarks>
        ///    Plugin authors are deliberately prevented from calling this constructor directly because it's signature may change
        ///    over time. In order to create an instance of this type, simply call <see cref="ILogSourceFactory.CreateMultiLineLogFile"/>.
        /// </remarks>
        /// <param name="taskScheduler"></param>
        /// <param name="source"></param>
        /// <param name="maximumWaitTime"></param>
        public MultiLineLogSource(ITaskScheduler taskScheduler, ILogSource source, TimeSpan maximumWaitTime)
            : base(taskScheduler)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            _maximumWaitTime      = maximumWaitTime;
            _pendingModifications = new ConcurrentQueue <LogSourceModification>();
            _syncRoot             = new object();
            _specialColumns       = new HashSet <IColumnDescriptor> {
                Core.Columns.LogEntryIndex, Core.Columns.Timestamp, Core.Columns.LogLevel
            };
            _indices = new List <LogEntryInfo>();

            // The log file we were given might offer even more properties than the minimum set and we
            // want to expose those as well.
            _propertiesBuffer = new PropertiesBufferList(Core.Properties.CombineWithMinimum(source.Properties));
            _propertiesBuffer.SetValue(Core.Properties.EmptyReason, null);

            _properties = new ConcurrentPropertiesList(Core.Properties.CombineWithMinimum(source.Properties));
            _properties.CopyFrom(_propertiesBuffer);

            _currentLogEntry = new LogEntryInfo(-1, 0);

            _source = source;
            _source.AddListener(this, maximumWaitTime, MaximumBatchSize);
            StartTask();
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        private void SynchronizePropertiesWithUser()
        {
            _localProperties.SetValue(TextProperties.LineCount, _entries.Count);
            _localProperties.SetValue(Core.Properties.LogEntryCount, _entries.Count);
            _localProperties.SetValue(Core.Properties.LogEntryCount, _entries.Count);

            // We want to update the user-facing properties in a single synchronized OP
            // so that the properties as retrieved by the user are in sync
            _properties.CopyFrom(_localProperties);
        }
Ejemplo n.º 4
0
 private void UpdateProperties()
 {
     if (_source != null)
     {
         _source.GetAllProperties(_sourceProperties);
         _properties.CopyFrom(_sourceProperties);
     }
     else
     {
         _properties.SetValue(Core.Properties.PercentageProcessed, Percentage.HundredPercent);
     }
 }
Ejemplo n.º 5
0
        private void UpdateProperties()
        {
            // First we want to retrieve all properties from the source
            _source.GetAllProperties(_propertiesBuffer);

            // Then we'll add / overwrite properties
            _propertiesBuffer.SetValue(Core.Properties.PercentageProcessed, ComputePercentageProcessed());
            _propertiesBuffer.SetValue(Core.Properties.LogEntryCount, _indices.Count);

            // And last but not least we'll update our own properties to the new values
            // It's important we do this in one go so clients can retrieve all those properties
            // in a consistent state
            _properties.CopyFrom(_propertiesBuffer);
        }
Ejemplo n.º 6
0
        private void UpdateProperties()
        {
            if (_finalLogSource != null)
            {
                _finalLogSource.GetAllProperties(_propertiesBuffer.Except(TextProperties.AutoDetectedEncoding, Core.Properties.Format));                 //< We don't want the log source to overwrite the encoding we just found out...
                _propertiesBuffer.SetValue(TextProperties.MaxCharactersInLine, _maxCharactersInLine);
            }
            else
            {
                _propertiesBuffer.SetValue(Core.Properties.PercentageProcessed, Percentage.HundredPercent);
            }

            _properties.CopyFrom(_propertiesBuffer);
        }
        private void SynchronizeProperties()
        {
            _source.GetAllProperties(_propertiesBuffer.Except(_adornedProperties));

            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);
            _properties.CopyFrom(_propertiesBuffer);
        }