Пример #1
0
		void FileSizeChanged(object sender, LogEventArgs e)
		{
			int diff = e.LineCount - e.PrevLineCount;
			if (diff < 0)
			{
				diff = DIFF_MAX;
				return;
			}
			lock (this.diffSumLock)
			{
				this.diffSum = this.diffSum + diff;
				if (this.diffSum > DIFF_MAX)
					this.diffSum = DIFF_MAX;
			}
			Dirty = true;
			Parent.Invalidate();
		}
Пример #2
0
 void OnFileSizeChanged(LogEventArgs e)
 {
     if (FileSizeChanged != null)
     {
         FileSizeChanged(this, e);
     }
 }
Пример #3
0
        protected void CheckFilterAndHighlight(LogEventArgs e)
        {
            bool noLed = true;
            bool suppressLed = false;
            bool setBookmark = false;
            bool stopTail = false;
            string bookmarkComment = null;
            if (filterTailCheckBox.Checked || _filterPipeList.Count > 0)
            {
                int filterStart = e.PrevLineCount;
                if (e.IsRollover)
                {
                    ShiftFilterLines(e.RolloverOffset);
                    filterStart -= e.RolloverOffset;
                }
                bool firstStopTail = true;
                ColumnizerCallback callback = new ColumnizerCallback(this);
                bool filterLineAdded = false;
                for (int i = filterStart; i < e.LineCount; ++i)
                {
                    string line = CurrentLogFileReader.GetLogLine(i);
                    if (line == null)
                    {
                        return;
                    }
                    if (filterTailCheckBox.Checked)
                    {
                        callback.LineNum = i;
                        if (Classes.DamerauLevenshtein.TestFilterCondition(_filterParams, line, callback))
                        {
                            filterLineAdded = true;
                            AddFilterLine(i, false, _filterParams, _filterResultList, _lastFilterLinesList, _filterHitList);
                        }
                    }
                    ProcessFilterPipes(i);

                    IList<HilightEntry> matchingList = FindMatchingHilightEntries(line);
                    LaunchHighlightPlugins(matchingList, i);
                    GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, out bookmarkComment);
                    if (setBookmark)
                    {
                        Action<int, string> fx = new Action<int, string>(SetBookmarkFromTrigger);
                        fx.BeginInvoke(i, bookmarkComment, null, null);
                    }
                    if (stopTail && _guiStateArgs.FollowTail)
                    {
                        bool wasFollow = _guiStateArgs.FollowTail;
                        FollowTailChanged(false, true);
                        if (firstStopTail && wasFollow)
                        {
                            Invoke(new Action<int, bool>(SelectAndEnsureVisible), new object[] { i, false });
                            firstStopTail = false;
                        }
                    }
                    if (!suppressLed)
                    {
                        noLed = false;
                    }
                }
                if (filterLineAdded)
                {
                    TriggerFilterLineGuiUpdate();
                }
            }
            else
            {
                bool firstStopTail = true;
                int startLine = e.PrevLineCount;
                if (e.IsRollover)
                {
                    ShiftFilterLines(e.RolloverOffset);
                    startLine -= e.RolloverOffset;
                }
                for (int i = startLine; i < e.LineCount; ++i)
                {
                    string line = CurrentLogFileReader.GetLogLine(i);
                    if (line != null)
                    {
                        IList<HilightEntry> matchingList = FindMatchingHilightEntries(line);
                        LaunchHighlightPlugins(matchingList, i);
                        GetHilightActions(matchingList, out suppressLed, out stopTail, out setBookmark, out bookmarkComment);
                        if (setBookmark)
                        {
                            Action<int, string> fx = new Action<int, string>(SetBookmarkFromTrigger);
                            fx.BeginInvoke(i, bookmarkComment, null, null);
                        }
                        if (stopTail && _guiStateArgs.FollowTail)
                        {
                            bool wasFollow = _guiStateArgs.FollowTail;
                            FollowTailChanged(false, true);
                            if (firstStopTail && wasFollow)
                            {
                                Invoke(new Action<int, bool>(SelectAndEnsureVisible), new object[] { i, false });
                                firstStopTail = false;
                            }
                        }
                        if (!suppressLed)
                        {
                            noLed = false;
                        }
                    }
                }
            }
            if (!noLed)
            {
                OnFileSizeChanged(e);
            }
        }
Пример #4
0
        protected void UpdateGrid(LogEventArgs e)
        {
            int oldRowCount = dataGridView.RowCount;
            int firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex;

            try
            {
                if (dataGridView.RowCount > e.LineCount)
                {
                    int currentLineNum = dataGridView.CurrentCellAddress.Y;
                    dataGridView.RowCount = 0;
                    dataGridView.RowCount = e.LineCount;
                    if (!_guiStateArgs.FollowTail)
                    {
                        if (currentLineNum >= dataGridView.RowCount)
                        {
                            currentLineNum = dataGridView.RowCount - 1;
                        }
                        dataGridView.CurrentCell = dataGridView.Rows[currentLineNum].Cells[0];
                    }
                }
                else
                {
                    dataGridView.RowCount = e.LineCount;
                }
                Logger.logDebug("UpdateGrid(): new RowCount=" + dataGridView.RowCount);
                if (e.IsRollover)
                {
                    // Multifile rollover
                    // keep selection and view range, if no follow tail mode
                    if (!_guiStateArgs.FollowTail)
                    {
                        int currentLineNum = dataGridView.CurrentCellAddress.Y;
                        currentLineNum -= e.RolloverOffset;
                        if (currentLineNum < 0)
                        {
                            currentLineNum = 0;
                        }
                        Logger.logDebug("UpdateGrid(): Rollover=true, Rollover offset=" + e.RolloverOffset + ", currLineNum was " + dataGridView.CurrentCellAddress.Y + ", new currLineNum=" + currentLineNum);
                        firstDisplayedLine -= e.RolloverOffset;
                        if (firstDisplayedLine < 0)
                        {
                            firstDisplayedLine = 0;
                        }
                        dataGridView.FirstDisplayedScrollingRowIndex = firstDisplayedLine;
                        dataGridView.CurrentCell = dataGridView.Rows[currentLineNum].Cells[0];
                        dataGridView.Rows[currentLineNum].Selected = true;
                    }
                }
                _statusEventArgs.LineCount = e.LineCount;
                StatusLineFileSize(e.FileSize);

                if (!_isLoading)
                {
                    if (oldRowCount == 0)
                    {
                        AdjustMinimumGridWith();
                    }
                }
                if (_guiStateArgs.FollowTail && dataGridView.RowCount > 0)
                {
                    dataGridView.FirstDisplayedScrollingRowIndex = dataGridView.RowCount - 1;
                    OnTailFollowed(new EventArgs());
                }
                if (Preferences.timestampControl && !_isLoading)
                {
                    SetTimestampLimits();
                }
            }
            catch (Exception ex)
            {
                Logger.logError("Fehler bei UpdateGrid(): " + ex + "\n" + ex.StackTrace);
            }
        }
Пример #5
0
        void FileSizeChangedHandler(object sender, LogEventArgs e)
        {
            Logger.logInfo("Got FileSizeChanged event. prevLines:" + e.PrevLineCount + ", curr lines: " + e.LineCount);

            lock (_logEventArgsList)
            {
                _logEventArgsList.Add(e);
                _logEventArgsEvent.Set();
            }
        }
Пример #6
0
		/// <summary>
		/// Public for unit test reasons
		/// </summary>
		public void ReadFiles()
		{
			_currFileSize = 0;
			LineCount = 0;
			//lastReturnedLine = "";
			//lastReturnedLineNum = -1;
			//lastReturnedLineNumForBuffer = -1;
			_isDeleted = false;
			ClearLru();
			AcquireBufferListWriterLock();
			_bufferList.Clear();
			ReleaseBufferListWriterLock();
			try
			{
				foreach (ILogFileInfo info in _logFileInfoList)
				{
					//info.OpenFile();
					ReadToBufferList(info, 0, LineCount);
				}
				if (_logFileInfoList.Count > 0)
				{
					ILogFileInfo info = _logFileInfoList[_logFileInfoList.Count - 1];
					_fileLength = info.Length;
					_watchedILogFileInfo = info;
				}
			}
			catch (IOException e)
			{
				Logger.logWarn(string.Format("IOException: {0}", e.Message));
				_fileLength = 0;
				_isDeleted = true;
				LineCount = 0;
			}
			LogEventArgs args = new LogEventArgs();
			args.PrevFileSize = 0;
			args.PrevLineCount = 0;
			args.LineCount = LineCount;
			args.FileSize = _currFileSize;
			OnFileSizeChanged(args);
		}
Пример #7
0
		protected virtual void OnFileSizeChanged(LogEventArgs e)
		{
			if (FileSizeChanged != null)
			{
				FileSizeChanged(this, e);
			}
		}
Пример #8
0
		private void FireChangeEvent()
		{
			LogEventArgs args = new LogEventArgs();
			args.PrevFileSize = _currFileSize;
			args.PrevLineCount = LineCount;
			long newSize = _fileLength;
			if (newSize < _currFileSize || _isDeleted)
			{
				Logger.logInfo(string.Format("File was created anew: new size={0}, oldSize={1}", newSize, _currFileSize));
				// Fire "New File" event
				_currFileSize = 0;
				LineCount = 0;
				try
				{
					if (!IsMultiFile)
					{
						// ReloadBufferList();  // removed because reloading is triggered by owning LogWindow
						// Trigger "new file" handling (reload)
						OnLoadFile(new LoadFileEventArgs(_fileName, 0, true, _fileLength, true));

						if (_isDeleted)
						{
							args.FileSize = newSize;
							args.LineCount = LineCount;
							if (args.PrevLineCount != args.LineCount && !_shouldStop)
							{
								OnFileSizeChanged(args);
							}
						}
						_isDeleted = false;
					}
					else
					{
						int offset = ShiftBuffers();
						//currFileSize = newSize;    // removed because ShiftBuffers() calls ReadToBuffer() which will set the actual read size
						args.FileSize = newSize;
						args.LineCount = LineCount;
						args.IsRollover = true;
						args.RolloverOffset = offset;
						_isDeleted = false;
						if (!_shouldStop)
						{
							OnFileSizeChanged(args);
						}
					}
				}
				catch (FileNotFoundException e)
				{
					// trying anew in next poll intervall. So let currFileSize untouched.
					Logger.logWarn(e.ToString());
					return;
				}
			}
			else
			{
				ReadToBufferList(_watchedILogFileInfo, _currFileSize > 0 ? _currFileSize : _currFileSize, LineCount);
				args.FileSize = newSize;
				args.LineCount = LineCount;
				//if (args.PrevLineCount != args.LineCount && !shouldStop)
				OnFileSizeChanged(args);
			}
		}