예제 #1
0
        private void Clear()
        {
            Listeners.Reset();

            lock (_syncRoot)
            {
                _lines.Clear();
            }
        }
예제 #2
0
        private void Reset()
        {
            _count = 0;
            try
            {
                OnResetSection();
            }
            catch (Exception e)
            {
                Log.WarnFormat("Caught unexpected exception: {0}", e);
            }

            SynchronizeProperties();
            Listeners.Reset();
        }
예제 #3
0
        private void OnReset(FileStream stream,
                             out int numberOfLinesRead,
                             out long lastPosition)
        {
            lastPosition = 0;
            if (stream != null)
            {
                stream.Position = 0;
            }

            numberOfLinesRead = 0;
            _entries.Clear();
            SynchronizePropertiesWithUser();

            Listeners.Reset();
        }
예제 #4
0
        private void OnReset(FileStream stream,
                             out int numberOfLinesRead,
                             out long lastPosition)
        {
            lastPosition = 0;
            if (stream != null)
            {
                stream.Position = 0;
            }

            numberOfLinesRead = 0;
            _properties.SetValue(LogFileProperties.StartTimestamp, null);
            _properties.SetValue(LogFileProperties.EndTimestamp, null);
            _maxCharactersPerLine = 0;

            _entries.Clear();
            Listeners.Reset();
        }
예제 #5
0
 private void NotifyListeners(IEnumerable <LogFileSection> changes)
 {
     foreach (var section in changes)
     {
         if (section.IsInvalidate)
         {
             Listeners.Invalidate((int)section.Index, section.Count);
         }
         else if (section.IsReset)
         {
             Listeners.Reset();
         }
         else
         {
             Listeners.OnRead((int)(section.Index + section.Count));
         }
     }
 }
예제 #6
0
 private void NotifyListeners(IEnumerable <LogSourceModification> changes)
 {
     foreach (var section in changes)
     {
         if (section.IsRemoved(out var removedSection))
         {
             Listeners.Remove((int)removedSection.Index, removedSection.Count);
         }
         else if (section.IsReset())
         {
             Listeners.Reset();
         }
         else if (section.IsAppended(out var appendedSection))
         {
             Listeners.OnRead((int)(appendedSection.Index + appendedSection.Count));
         }
     }
 }
예제 #7
0
        private void ProcessPendingSections(out bool workDone)
        {
            workDone = false;
            while (_pendingSections.TryDequeue(out var pair))
            {
                // We may still have pending sections from a log file we've just removed as listener.
                // If that's the case, then throw away that section and go look for the next...
                if (!Equals(pair.Key, _finalLogSource))
                {
                    continue;
                }

                var modification = pair.Value;
                if (modification.IsReset())
                {
                    Listeners.Reset();
                    _count = 0;
                    _maxCharactersInLine = 0;
                }
                else if (modification.IsRemoved(out var removedSection))
                {
                    Listeners.Remove((int)removedSection.Index, removedSection.Count);
                    _count = (int)removedSection.Index;
                    // TODO: What about max width?
                }
                else if (modification.IsAppended(out var appendedSection))
                {
                    Listeners.OnRead(appendedSection.LastIndex);
                    _count = (int)(appendedSection.Index + appendedSection.Count);
                    UpdateMaxWidth(appendedSection, pair.Key);
                }

                workDone = true;
            }

            if (!workDone)
            {
                Listeners.OnRead(_count);
            }
        }
예제 #8
0
        private void Clear(ILogFile logFile)
        {
            var numRemoved = 0;

            lock (_syncRoot)
            {
                for (var i = _indices.Count - 1; i >= 0; --i)
                {
                    var index        = _indices[i];
                    var indexLogFile = _sources[index.LogFileIndex];
                    if (indexLogFile == logFile)
                    {
                        _indices.RemoveAt(i);
                        ++numRemoved;
                    }
                }
            }

            if (numRemoved > 0)
            {
                Listeners.Reset();
                Listeners.OnRead(_indices.Count);
            }
        }