diff --git a/src/ColumnizerLib/IAutoLogLineColumnizerCallback.cs b/src/ColumnizerLib/IAutoLogLineColumnizerCallback.cs
index 8889c8f9..25b315d9 100644
--- a/src/ColumnizerLib/IAutoLogLineColumnizerCallback.cs
+++ b/src/ColumnizerLib/IAutoLogLineColumnizerCallback.cs
@@ -1,4 +1,4 @@
-namespace LogExpert
+namespace LogExpert
{
public interface IAutoLogLineColumnizerCallback
{
@@ -7,6 +7,6 @@ public interface IAutoLogLineColumnizerCallback
///
/// Number of the line to be retrieved
/// A string with line content or null if line number is out of range
- ILogLine GetLogLine(int lineNum);
+ ILogLine GetLogLine (int lineNum);
}
}
\ No newline at end of file
diff --git a/src/ColumnizerLib/ILogLineColumnizerCallback.cs b/src/ColumnizerLib/ILogLineColumnizerCallback.cs
index 270b9b40..2c5f5811 100644
--- a/src/ColumnizerLib/ILogLineColumnizerCallback.cs
+++ b/src/ColumnizerLib/ILogLineColumnizerCallback.cs
@@ -1,47 +1,52 @@
-namespace LogExpert
+namespace LogExpert;
+
+///
+///This is a callback interface. Some of the ILogLineColumnizer functions
+///are called with this interface as an argument. You don't have to implement this interface. It's implemented
+///by LogExpert. You can use it in your own columnizers, if you need it.
+///
+///
+///Implementors of ILogLineColumnizer can use the provided functions to get some more informations
+///about the log file. In the most cases you don't need this interface. It's provided here for special cases.
+///
+///An example would be when the log lines contains only the time of day but the date is coded in the file name. In this situation
+///you can use the GetFileName() function to retrieve the name of the current file to build a complete timestamp.
+///
+public interface ILogLineColumnizerCallback
{
- ///
- ///This is a callback interface. Some of the ILogLineColumnizer functions
- ///are called with this interface as an argument. You don't have to implement this interface. It's implemented
- ///by LogExpert. You can use it in your own columnizers, if you need it.
- ///
- ///
- ///Implementors of ILogLineColumnizer can use the provided functions to get some more informations
- ///about the log file. In the most cases you don't need this interface. It's provided here for special cases.
- ///
- ///An example would be when the log lines contains only the time of day but the date is coded in the file name. In this situation
- ///you can use the GetFileName() function to retrieve the name of the current file to build a complete timestamp.
- ///
- public interface ILogLineColumnizerCallback
- {
- #region Public methods
+ #region Public methods
- ///
- /// This function returns the current line number. That is the line number of the log line
- /// a ILogLineColumnizer function is called for (e.g. the line that has to be painted).
- ///
- /// The current line number starting at 0
- int GetLineNum();
+ ///
+ /// This function returns the current line number. That is the line number of the log line
+ /// a ILogLineColumnizer function is called for (e.g. the line that has to be painted).
+ ///
+ /// The current line number starting at 0
+ int GetLineNum ();
- ///
- /// Returns the full file name (path + name) of the current log file.
- ///
- /// File name of current log file
- string GetFileName();
+ ///
+ /// This function sets the current line number. That is the line number of the log line
+ /// a ILogLineColumnizer function is called for (e.g. the line that has to be painted).
+ ///
+ /// line number to be set
+ void SetLineNum (int lineNum);
+ ///
+ /// Returns the full file name (path + name) of the current log file.
+ ///
+ /// File name of current log file
+ string GetFileName ();
- ///
- /// Returns the log line with the given index (zero-based).
- ///
- /// Number of the line to be retrieved
- /// A string with line content or null if line number is out of range
- ILogLine GetLogLine(int lineNum);
+ ///
+ /// Returns the log line with the given index (zero-based).
+ ///
+ /// Number of the line to be retrieved
+ /// A string with line content or null if line number is out of range
+ ILogLine GetLogLine (int lineNum);
- ///
- /// Returns the number of lines of the logfile.
- ///
- /// Number of lines.
- int GetLineCount();
+ ///
+ /// Returns the number of lines of the logfile.
+ ///
+ /// Number of lines.
+ int GetLineCount ();
- #endregion
- }
+ #endregion
}
\ No newline at end of file
diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props
index 533ca233..4fff1524 100644
--- a/src/Directory.Packages.props
+++ b/src/Directory.Packages.props
@@ -28,7 +28,7 @@
-
+
diff --git a/src/LogExpert.Core/Callback/ColumnizerCallback.cs b/src/LogExpert.Core/Callback/ColumnizerCallback.cs
index 4168713e..2d1266b1 100644
--- a/src/LogExpert.Core/Callback/ColumnizerCallback.cs
+++ b/src/LogExpert.Core/Callback/ColumnizerCallback.cs
@@ -1,69 +1,70 @@
-using LogExpert.Core.Interface;
+using LogExpert.Core.Interface;
-namespace LogExpert.Classes.ILogLineColumnizerCallback
-{
- public class ColumnizerCallback : LogExpert.ILogLineColumnizerCallback, IAutoLogLineColumnizerCallback
- {
- #region Fields
+namespace LogExpert.Core.Callback;
- protected ILogWindow _logWindow;
- protected IPluginRegistry _pluginRegistry;
+public class ColumnizerCallback : ILogLineColumnizerCallback, IAutoLogLineColumnizerCallback
+{
+ #region cTor
- #endregion
+ public ColumnizerCallback (ILogWindow logWindow)
+ {
+ LogWindow = logWindow;
+ }
- #region cTor
+ private ColumnizerCallback (ColumnizerCallback original)
+ {
+ LogWindow = original.LogWindow;
+ LineNum = original.GetLineNum();
+ }
- public ColumnizerCallback(ILogWindow logWindow)
- {
- _logWindow = logWindow;
- }
+ #endregion
- private ColumnizerCallback(ColumnizerCallback original)
- {
- _logWindow = original._logWindow;
- LineNum = original.LineNum;
- }
+ #region Properties
- #endregion
+ public int LineNum { get; set; }
- #region Properties
+ protected ILogWindow LogWindow { get; set; }
- public int LineNum { get; set; }
+ protected IPluginRegistry PluginRegistry { get; set; }
- #endregion
+ #endregion
- #region Public methods
+ #region Public methods
- public ColumnizerCallback CreateCopy()
- {
- return new ColumnizerCallback(this);
- }
+ public ColumnizerCallback CreateCopy ()
+ {
+ return new ColumnizerCallback(this);
+ }
- public int GetLineNum()
- {
- return LineNum;
- }
+ public int GetLineNum ()
+ {
+ return LineNum;
+ }
- public string GetFileName()
- {
- return _logWindow.GetCurrentFileName(LineNum);
- }
+ public string GetFileName ()
+ {
+ return LogWindow.GetCurrentFileName(GetLineNum());
+ }
- public ILogLine GetLogLine(int lineNum)
- {
- return _logWindow.GetLine(lineNum);
- }
+ public ILogLine GetLogLine (int lineNum)
+ {
+ return LogWindow.GetLine(lineNum);
+ }
- public IList GetRegisteredColumnizers()
- {
- return _pluginRegistry.RegisteredColumnizers;
- }
+ public IList GetRegisteredColumnizers ()
+ {
+ return PluginRegistry.RegisteredColumnizers;
+ }
- public int GetLineCount()
- {
- return _logWindow._logFileReader.LineCount;
- }
+ public int GetLineCount ()
+ {
+ return LogWindow.LogFileReader.LineCount;
+ }
- #endregion
+ public void SetLineNum (int lineNum)
+ {
+ LineNum = lineNum;
}
+
+ #endregion
}
diff --git a/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs b/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs
index 58f15b05..9ca62371 100644
--- a/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs
+++ b/src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs
@@ -1,6 +1,3 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Text.RegularExpressions;
using static LogExpert.Core.Classes.Columnizer.TimeFormatDeterminer;
@@ -18,11 +15,11 @@ public class SquareBracketColumnizer : ILogLineColumnizer, IColumnizerPriority
private int _columnCount = 5;
private bool _isTimeExists = false;
- public SquareBracketColumnizer()
+ public SquareBracketColumnizer ()
{
}
- public SquareBracketColumnizer(int columnCount, bool isTimeExists) : this()
+ public SquareBracketColumnizer (int columnCount, bool isTimeExists) : this()
{
// Add message column
_columnCount = columnCount + 1;
@@ -34,22 +31,22 @@ public SquareBracketColumnizer(int columnCount, bool isTimeExists) : this()
}
}
- public bool IsTimeshiftImplemented()
+ public bool IsTimeshiftImplemented ()
{
return true;
}
- public void SetTimeOffset(int msecOffset)
+ public void SetTimeOffset (int msecOffset)
{
timeOffset = msecOffset;
}
- public int GetTimeOffset()
+ public int GetTimeOffset ()
{
return timeOffset;
}
- public DateTime GetTimestamp(LogExpert.ILogLineColumnizerCallback callback, ILogLine line)
+ public DateTime GetTimestamp (LogExpert.ILogLineColumnizerCallback callback, ILogLine line)
{
IColumnizedLogLine cols = SplitLine(callback, line);
if (cols == null || cols.ColumnValues == null || cols.ColumnValues.Length < 2)
@@ -81,7 +78,7 @@ public DateTime GetTimestamp(LogExpert.ILogLineColumnizerCallback callback, ILog
}
}
- public void PushValue(LogExpert.ILogLineColumnizerCallback callback, int column, string value, string oldValue)
+ public void PushValue (LogExpert.ILogLineColumnizerCallback callback, int column, string value, string oldValue)
{
if (column == 1)
{
@@ -105,22 +102,22 @@ public void PushValue(LogExpert.ILogLineColumnizerCallback callback, int column,
}
}
- public string GetName()
+ public string GetName ()
{
return "Square Bracket Columnizer";
}
- public string GetDescription()
+ public string GetDescription ()
{
return "Splits every line into n fields: Date, Time and the rest of the log message";
}
- public int GetColumnCount()
+ public int GetColumnCount ()
{
return _columnCount;
}
- public string[] GetColumnNames()
+ public string[] GetColumnNames ()
{
var columnNames = new List(GetColumnCount());
if (_isTimeExists)
@@ -151,7 +148,7 @@ public string[] GetColumnNames()
return columnNames.ToArray();
}
- public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callback, ILogLine line)
+ public IColumnizedLogLine SplitLine (LogExpert.ILogLineColumnizerCallback callback, ILogLine line)
{
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
@@ -217,7 +214,7 @@ public IColumnizedLogLine SplitLine(LogExpert.ILogLineColumnizerCallback callbac
return clogLine;
}
- void SquareSplit(ref Column[] columns, string line, int dateLen, int timeLen, int dateTimeEndPos, ColumnizedLogLine clogLine)
+ void SquareSplit (ref Column[] columns, string line, int dateLen, int timeLen, int dateTimeEndPos, ColumnizedLogLine clogLine)
{
List columnList = [];
int restColumn = _columnCount;
@@ -256,7 +253,7 @@ void SquareSplit(ref Column[] columns, string line, int dateLen, int timeLen, in
columns = columnList.ToArray();
}
- public Priority GetPriority(string fileName, IEnumerable samples)
+ public Priority GetPriority (string fileName, IEnumerable samples)
{
Priority result = Priority.NotSupport;
TimeFormatDeterminer timeDeterminer = new();
diff --git a/src/LogExpert.Core/Classes/Filter/Filter.cs b/src/LogExpert.Core/Classes/Filter/Filter.cs
index f716fad9..f7ee2603 100644
--- a/src/LogExpert.Core/Classes/Filter/Filter.cs
+++ b/src/LogExpert.Core/Classes/Filter/Filter.cs
@@ -1,11 +1,11 @@
-using LogExpert.Classes.ILogLineColumnizerCallback;
+using LogExpert.Core.Callback;
using LogExpert.Core.Classes;
using LogExpert.Core.Classes.Filter;
using NLog;
namespace LogExpert.Classes.Filter
{
- internal delegate void FilterFx(FilterParams filterParams, List filterResultLines, List lastFilterResultLines, List filterHitList);
+ internal delegate void FilterFx (FilterParams filterParams, List filterResultLines, List lastFilterResultLines, List filterHitList);
internal class Filter
{
@@ -21,8 +21,8 @@ internal class Filter
#region cTor
- //TODO Is the callback needed?
- public Filter(ColumnizerCallback callback)
+ //TODO Is the callback needed? (https://github.com/LogExperts/LogExpert/issues/401)
+ public Filter (ColumnizerCallback callback)
{
_callback = callback;
FilterResultLines = [];
@@ -46,7 +46,7 @@ public Filter(ColumnizerCallback callback)
#region Public methods
- public int DoFilter(FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback)
+ public int DoFilter (FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback)
{
return DoFilter(filterParams, startLine, maxCount, FilterResultLines, LastFilterLinesList, FilterHitList, progressCallback);
}
@@ -55,16 +55,16 @@ public int DoFilter(FilterParams filterParams, int startLine, int maxCount, Prog
#region Private Methods
- private int DoFilter(FilterParams filterParams, int startLine, int maxCount, List filterResultLines,
- List lastFilterLinesList, List filterHitList, ProgressCallback progressCallback)
+ private int DoFilter (FilterParams filterParams, int startLine, int maxCount, List filterResultLines, List lastFilterLinesList, List filterHitList, ProgressCallback progressCallback)
{
- int lineNum = startLine;
- int count = 0;
- int callbackCounter = 0;
+ var lineNum = startLine;
+ var count = 0;
+ var callbackCounter = 0;
try
{
filterParams.Reset();
+
while ((count++ < maxCount || filterParams.IsInRange) && !ShouldCancel)
{
if (lineNum >= _callback.GetLineCount())
@@ -73,16 +73,17 @@ private int DoFilter(FilterParams filterParams, int startLine, int maxCount, Lis
}
ILogLine line = _callback.GetLogLine(lineNum);
+
if (line == null)
{
return count;
}
- _callback.LineNum = lineNum;
+ _callback.SetLineNum(lineNum);
+
if (Util.TestFilterCondition(filterParams, line, _callback))
{
- AddFilterLine(lineNum, false, filterParams, filterResultLines, lastFilterLinesList,
- filterHitList);
+ AddFilterLine(lineNum, false, filterParams, filterResultLines, lastFilterLinesList, filterHitList);
}
lineNum++;
@@ -107,7 +108,7 @@ private int DoFilter(FilterParams filterParams, int startLine, int maxCount, Lis
return count;
}
- private void AddFilterLine(int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList)
+ private void AddFilterLine (int lineNum, bool immediate, FilterParams filterParams, List filterResultLines, List lastFilterLinesList, List filterHitList)
{
filterHitList.Add(lineNum);
IList filterResult = GetAdditionalFilterResults(filterParams, lineNum, lastFilterLinesList);
@@ -132,7 +133,7 @@ private void AddFilterLine(int lineNum, bool immediate, FilterParams filterParam
///
///
///
- private IList GetAdditionalFilterResults(FilterParams filterParams, int lineNum, IList checkList)
+ private IList GetAdditionalFilterResults (FilterParams filterParams, int lineNum, IList checkList)
{
IList resultList = [];
diff --git a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs
index 672f33c8..c3956c6d 100644
--- a/src/LogExpert.Core/Classes/Filter/FilterStarter.cs
+++ b/src/LogExpert.Core/Classes/Filter/FilterStarter.cs
@@ -1,16 +1,11 @@
-using LogExpert.Classes.ILogLineColumnizerCallback;
+using LogExpert.Core.Callback;
using LogExpert.Core.Classes.Filter;
using NLog;
-using System;
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-
namespace LogExpert.Classes.Filter
{
- public delegate void ProgressCallback(int lineCount);
+ public delegate void ProgressCallback (int lineCount);
public class FilterStarter
{
@@ -35,7 +30,7 @@ public class FilterStarter
#region cTor
- public FilterStarter(ColumnizerCallback callback, int minThreads)
+ public FilterStarter (ColumnizerCallback callback, int minThreads)
{
_callback = callback;
FilterResultLines = [];
@@ -69,7 +64,7 @@ public FilterStarter(ColumnizerCallback callback, int minThreads)
#region Public methods
- public async void DoFilter(FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback)
+ public async void DoFilter (FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback)
{
FilterResultLines.Clear();
LastFilterLinesList.Clear();
@@ -87,6 +82,7 @@ public async void DoFilter(FilterParams filterParams, int startLine, int maxCoun
{
interval = 1;
}
+
int workStartLine = startLine;
List handleList = [];
_progressLineCount = 0;
@@ -121,7 +117,7 @@ public async void DoFilter(FilterParams filterParams, int startLine, int maxCoun
/// Requests the FilterStarter to stop all filter threads. Call this from another thread (e.g. GUI). The function returns
/// immediately without waiting for filter end.
///
- public void CancelFilter()
+ public void CancelFilter ()
{
_shouldStop = true;
lock (_filterWorkerList)
@@ -138,13 +134,13 @@ public void CancelFilter()
#region Private Methods
- private void ThreadProgressCallback(int lineCount)
+ private void ThreadProgressCallback (int lineCount)
{
int count = Interlocked.Add(ref _progressLineCount, lineCount);
_progressCallback(count);
}
- private Filter DoWork(FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback)
+ private Filter DoWork (FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback)
{
_logger.Info("Started Filter worker [{0}] for line {1}", Environment.CurrentManagedThreadId, startLine);
@@ -174,7 +170,7 @@ private Filter DoWork(FilterParams filterParams, int startLine, int maxCount, Pr
return filter;
}
- private void FilterDoneCallback(Task filterTask)
+ private void FilterDoneCallback (Task filterTask)
{
if (filterTask.IsCompleted)
{
@@ -187,7 +183,7 @@ private void FilterDoneCallback(Task filterTask)
}
}
- private void MergeResults()
+ private void MergeResults ()
{
_logger.Info("Merging filter results.");
foreach (Filter filter in _filterReadyList)
diff --git a/src/LogExpert.Core/Classes/Log/LogfileReader.cs b/src/LogExpert.Core/Classes/Log/LogfileReader.cs
index 944e4624..aa236303 100644
--- a/src/LogExpert.Core/Classes/Log/LogfileReader.cs
+++ b/src/LogExpert.Core/Classes/Log/LogfileReader.cs
@@ -1,940 +1,955 @@
-using LogExpert.Core.Classes.xml;
+using System.Text;
+
+using LogExpert.Core.Classes.xml;
using LogExpert.Core.Entities;
using LogExpert.Core.EventArguments;
using LogExpert.Core.EventHandlers;
using LogExpert.Core.Interface;
+
using NLog;
-using System.Text;
-namespace LogExpert.Core.Classes.Log
+namespace LogExpert.Core.Classes.Log;
+
+public class LogfileReader : IAutoLogLineColumnizerCallback
{
- public class LogfileReader : IAutoLogLineColumnizerCallback
- {
- #region Fields
+ #region Fields
- private static readonly ILogger _logger = LogManager.GetCurrentClassLogger();
+ private static readonly ILogger _logger = LogManager.GetCurrentClassLogger();
- private readonly GetLogLineFx _logLineFx;
+ private readonly GetLogLineFx _logLineFx;
- private readonly string _fileName;
- private readonly int _MAX_BUFFERS = 10;
- private readonly int _MAX_LINES_PER_BUFFER = 100;
+ private readonly string _fileName;
+ private readonly int _MAX_BUFFERS = 10;
+ private readonly int _MAX_LINES_PER_BUFFER = 100;
- private readonly object _monitor = new();
- private readonly MultiFileOptions _multiFileOptions;
- private readonly IPluginRegistry _pluginRegistry;
- private IList _bufferList;
- private ReaderWriterLock _bufferListLock;
- private IList _bufferLru;
- private bool _contentDeleted;
- private int _currLineCount;
- private ReaderWriterLock _disposeLock;
- private EncodingOptions _encodingOptions;
- private long _fileLength;
+ private readonly object _monitor = new();
+ private readonly MultiFileOptions _multiFileOptions;
+ private readonly IPluginRegistry _pluginRegistry;
+ private IList _bufferList;
+ private ReaderWriterLock _bufferListLock;
+ private IList _bufferLru;
+ private bool _contentDeleted;
+ private int _currLineCount;
+ private ReaderWriterLock _disposeLock;
+ private EncodingOptions _encodingOptions;
+ private long _fileLength;
- private Task _garbageCollectorTask;
- private Task _monitorTask;
- private readonly CancellationTokenSource cts = new();
+ private Task _garbageCollectorTask;
+ private Task _monitorTask;
+ private readonly CancellationTokenSource cts = new();
- private bool _isDeleted;
- private bool _isFailModeCheckCallPending;
- private bool _isFastFailOnGetLogLine;
- private bool _isLineCountDirty = true;
- private IList _logFileInfoList = [];
- private Dictionary _lruCacheDict;
+ private bool _isDeleted;
+ private bool _isFailModeCheckCallPending;
+ private bool _isFastFailOnGetLogLine;
+ private bool _isLineCountDirty = true;
+ private IList _logFileInfoList = [];
+ private Dictionary _lruCacheDict;
- private ReaderWriterLock _lruCacheDictLock;
+ private ReaderWriterLock _lruCacheDictLock;
- private bool _shouldStop;
- private ILogFileInfo _watchedILogFileInfo;
+ private bool _shouldStop;
+ private ILogFileInfo _watchedILogFileInfo;
- #endregion
+ #endregion
- #region cTor
+ #region cTor
- public LogfileReader(string fileName, EncodingOptions encodingOptions, bool multiFile, int bufferCount, int linesPerBuffer, MultiFileOptions multiFileOptions, IPluginRegistry pluginRegistry)
+ public LogfileReader (string fileName, EncodingOptions encodingOptions, bool multiFile, int bufferCount, int linesPerBuffer, MultiFileOptions multiFileOptions, IPluginRegistry pluginRegistry)
+ {
+ if (fileName == null)
{
- if (fileName == null)
- {
- return;
- }
+ return;
+ }
- _fileName = fileName;
- EncodingOptions = encodingOptions;
- IsMultiFile = multiFile;
- _MAX_BUFFERS = bufferCount;
- _MAX_LINES_PER_BUFFER = linesPerBuffer;
- _multiFileOptions = multiFileOptions;
- _pluginRegistry = pluginRegistry;
- _logLineFx = GetLogLineInternal;
- InitLruBuffers();
-
- if (multiFile)
- {
- ILogFileInfo info = GetLogFileInfo(fileName);
- RolloverFilenameHandler rolloverHandler = new(info, _multiFileOptions);
- LinkedList nameList = rolloverHandler.GetNameList(_pluginRegistry);
+ _fileName = fileName;
+ EncodingOptions = encodingOptions;
+ IsMultiFile = multiFile;
+ _MAX_BUFFERS = bufferCount;
+ _MAX_LINES_PER_BUFFER = linesPerBuffer;
+ _multiFileOptions = multiFileOptions;
+ _pluginRegistry = pluginRegistry;
+ _logLineFx = GetLogLineInternal;
+ InitLruBuffers();
- ILogFileInfo fileInfo = null;
- foreach (string name in nameList)
- {
- fileInfo = AddFile(name);
- }
+ if (multiFile)
+ {
+ ILogFileInfo info = GetLogFileInfo(fileName);
+ RolloverFilenameHandler rolloverHandler = new(info, _multiFileOptions);
+ LinkedList nameList = rolloverHandler.GetNameList(_pluginRegistry);
- _watchedILogFileInfo = fileInfo; // last added file in the list is the watched file
- }
- else
+ ILogFileInfo fileInfo = null;
+ foreach (string name in nameList)
{
- _watchedILogFileInfo = AddFile(fileName);
+ fileInfo = AddFile(name);
}
- StartGCThread();
+ _watchedILogFileInfo = fileInfo; // last added file in the list is the watched file
}
-
- public LogfileReader(string[] fileNames, EncodingOptions encodingOptions, int bufferCount, int linesPerBuffer, MultiFileOptions multiFileOptions, IPluginRegistry pluginRegistry)
+ else
{
- if (fileNames == null || fileNames.Length < 1)
- {
- return;
- }
+ _watchedILogFileInfo = AddFile(fileName);
+ }
- EncodingOptions = encodingOptions;
- IsMultiFile = true;
- _MAX_BUFFERS = bufferCount;
- _MAX_LINES_PER_BUFFER = linesPerBuffer;
- _multiFileOptions = multiFileOptions;
- _pluginRegistry = pluginRegistry;
- _logLineFx = GetLogLineInternal;
+ StartGCThread();
+ }
- InitLruBuffers();
+ public LogfileReader (string[] fileNames, EncodingOptions encodingOptions, int bufferCount, int linesPerBuffer, MultiFileOptions multiFileOptions, IPluginRegistry pluginRegistry)
+ {
+ if (fileNames == null || fileNames.Length < 1)
+ {
+ return;
+ }
- ILogFileInfo fileInfo = null;
- foreach (string name in fileNames)
- {
- fileInfo = AddFile(name);
- }
+ EncodingOptions = encodingOptions;
+ IsMultiFile = true;
+ _MAX_BUFFERS = bufferCount;
+ _MAX_LINES_PER_BUFFER = linesPerBuffer;
+ _multiFileOptions = multiFileOptions;
+ _pluginRegistry = pluginRegistry;
+ _logLineFx = GetLogLineInternal;
- _watchedILogFileInfo = fileInfo;
- _fileName = fileInfo.FullName;
+ InitLruBuffers();
- StartGCThread();
+ ILogFileInfo fileInfo = null;
+ foreach (string name in fileNames)
+ {
+ fileInfo = AddFile(name);
}
- #endregion
+ _watchedILogFileInfo = fileInfo;
+ _fileName = fileInfo.FullName;
- #region Delegates
+ StartGCThread();
+ }
- public delegate void BlockLoadedEventHandler(object sender, LoadFileEventArgs e);
- public delegate void FileNotFoundEventHandler(object sender, EventArgs e);
- public delegate void FileRespawnedEventHandler(object sender, EventArgs e);
- public delegate void FinishedLoadingEventHandler(object sender, EventArgs e);
- private delegate Task GetLogLineFx(int lineNum);
- public delegate void LoadingStartedEventHandler(object sender, LoadFileEventArgs e);
+ #endregion
- #endregion
+ #region Delegates
- #region Events
+ public delegate void BlockLoadedEventHandler (object sender, LoadFileEventArgs e);
+ public delegate void FileNotFoundEventHandler (object sender, EventArgs e);
+ public delegate void FileRespawnedEventHandler (object sender, EventArgs e);
+ public delegate void FinishedLoadingEventHandler (object sender, EventArgs e);
+ private delegate Task GetLogLineFx (int lineNum);
+ public delegate void LoadingStartedEventHandler (object sender, LoadFileEventArgs e);
- public event FileSizeChangedEventHandler FileSizeChanged;
- public event BlockLoadedEventHandler LoadFile;
- public event LoadingStartedEventHandler LoadingStarted;
- public event FinishedLoadingEventHandler LoadingFinished;
- public event FileNotFoundEventHandler FileNotFound;
- public event FileRespawnedEventHandler Respawned;
+ #endregion
- #endregion
+ #region Events
- #region Properties
+ public event FileSizeChangedEventHandler FileSizeChanged;
+ public event BlockLoadedEventHandler LoadFile;
+ public event LoadingStartedEventHandler LoadingStarted;
+ public event FinishedLoadingEventHandler LoadingFinished;
+ public event FileNotFoundEventHandler FileNotFound;
+ public event FileRespawnedEventHandler Respawned;
- public int LineCount
+ #endregion
+
+ #region Properties
+
+ public int LineCount
+ {
+ get
{
- get
+ if (_isLineCountDirty)
{
- if (_isLineCountDirty)
+ _currLineCount = 0;
+ AcquireBufferListReaderLock();
+ foreach (LogBuffer buffer in _bufferList)
{
- _currLineCount = 0;
- AcquireBufferListReaderLock();
- foreach (LogBuffer buffer in _bufferList)
- {
- _currLineCount += buffer.LineCount;
- }
-
- ReleaseBufferListReaderLock();
- _isLineCountDirty = false;
+ _currLineCount += buffer.LineCount;
}
- return _currLineCount;
+ ReleaseBufferListReaderLock();
+ _isLineCountDirty = false;
}
- set => _currLineCount = value;
+
+ return _currLineCount;
}
+ set => _currLineCount = value;
+ }
- public bool IsMultiFile { get; }
+ public bool IsMultiFile { get; }
- public Encoding CurrentEncoding { get; private set; }
+ public Encoding CurrentEncoding { get; private set; }
- public long FileSize { get; private set; }
+ public long FileSize { get; private set; }
- public bool IsXmlMode { get; set; } = false;
+ public bool IsXmlMode { get; set; } = false;
- public IXmlLogConfiguration XmlLogConfig { get; set; }
+ public IXmlLogConfiguration XmlLogConfig { get; set; }
- public IPreProcessColumnizer PreProcessColumnizer { get; set; } = null;
+ public IPreProcessColumnizer PreProcessColumnizer { get; set; } = null;
- public EncodingOptions EncodingOptions
+ public EncodingOptions EncodingOptions
+ {
+ get => _encodingOptions;
+ set
{
- get => _encodingOptions;
- set
{
+ _encodingOptions = new EncodingOptions
{
- _encodingOptions = new EncodingOptions
- {
- DefaultEncoding = value.DefaultEncoding,
- Encoding = value.Encoding
- };
- }
+ DefaultEncoding = value.DefaultEncoding,
+ Encoding = value.Encoding
+ };
}
}
+ }
- public bool UseNewReader { get; set; }
+ public bool UseNewReader { get; set; }
- #endregion
+ #endregion
- #region Public methods
+ #region Public methods
- ///
- /// Public for unit test reasons
- ///
- public void ReadFiles()
+ ///
+ /// Public for unit test reasons
+ ///
+ public void ReadFiles ()
+ {
+ FileSize = 0;
+ LineCount = 0;
+ //this.lastReturnedLine = "";
+ //this.lastReturnedLineNum = -1;
+ //this.lastReturnedLineNumForBuffer = -1;
+ _isDeleted = false;
+ ClearLru();
+ AcquireBufferListWriterLock();
+ _bufferList.Clear();
+ ReleaseBufferListWriterLock();
+ try
{
- FileSize = 0;
- LineCount = 0;
- //this.lastReturnedLine = "";
- //this.lastReturnedLineNum = -1;
- //this.lastReturnedLineNumForBuffer = -1;
- _isDeleted = false;
- ClearLru();
- AcquireBufferListWriterLock();
- _bufferList.Clear();
- ReleaseBufferListWriterLock();
- try
+ foreach (ILogFileInfo info in _logFileInfoList)
{
- 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;
- }
+ //info.OpenFile();
+ ReadToBufferList(info, 0, LineCount);
}
- catch (IOException e)
+
+ if (_logFileInfoList.Count > 0)
{
- _logger.Warn(e, "IOException");
- _fileLength = 0;
- _isDeleted = true;
- LineCount = 0;
+ ILogFileInfo info = _logFileInfoList[_logFileInfoList.Count - 1];
+ _fileLength = info.Length;
+ _watchedILogFileInfo = info;
}
+ }
+ catch (IOException e)
+ {
+ _logger.Warn(e, "IOException");
+ _fileLength = 0;
+ _isDeleted = true;
+ LineCount = 0;
+ }
- LogEventArgs args = new()
- {
- PrevFileSize = 0,
- PrevLineCount = 0,
- LineCount = LineCount,
- FileSize = FileSize
- };
+ LogEventArgs args = new()
+ {
+ PrevFileSize = 0,
+ PrevLineCount = 0,
+ LineCount = LineCount,
+ FileSize = FileSize
+ };
- OnFileSizeChanged(args);
- }
+ OnFileSizeChanged(args);
+ }
- ///
- /// Public for unit tests.
- ///
- ///
- public int ShiftBuffers()
+ ///
+ /// Public for unit tests.
+ ///
+ ///
+ public int ShiftBuffers ()
+ {
+ _logger.Info("ShiftBuffers() begin for {0}{1}", _fileName, IsMultiFile ? " (MultiFile)" : "");
+ AcquireBufferListWriterLock();
+ int offset = 0;
+ _isLineCountDirty = true;
+ lock (_monitor)
{
- _logger.Info("ShiftBuffers() begin for {0}{1}", _fileName, IsMultiFile ? " (MultiFile)" : "");
- AcquireBufferListWriterLock();
- int offset = 0;
- _isLineCountDirty = true;
- lock (_monitor)
- {
- RolloverFilenameHandler rolloverHandler = new(_watchedILogFileInfo, _multiFileOptions);
- LinkedList fileNameList = rolloverHandler.GetNameList(_pluginRegistry);
-
- ResetBufferCache();
- IList lostILogFileInfoList = [];
- IList readNewILogFileInfoList = [];
- IList newFileInfoList = [];
- IEnumerator enumerator = _logFileInfoList.GetEnumerator();
- while (enumerator.MoveNext())
+ RolloverFilenameHandler rolloverHandler = new(_watchedILogFileInfo, _multiFileOptions);
+ LinkedList fileNameList = rolloverHandler.GetNameList(_pluginRegistry);
+
+ ResetBufferCache();
+ IList lostILogFileInfoList = [];
+ IList readNewILogFileInfoList = [];
+ IList newFileInfoList = [];
+ IEnumerator enumerator = _logFileInfoList.GetEnumerator();
+ while (enumerator.MoveNext())
+ {
+ ILogFileInfo logFileInfo = enumerator.Current;
+ string fileName = logFileInfo.FullName;
+ _logger.Debug("Testing file {0}", fileName);
+ LinkedListNode node = fileNameList.Find(fileName);
+ if (node == null)
{
- ILogFileInfo logFileInfo = enumerator.Current;
- string fileName = logFileInfo.FullName;
- _logger.Debug("Testing file {0}", fileName);
- LinkedListNode node = fileNameList.Find(fileName);
- if (node == null)
+ _logger.Warn("File {0} not found", fileName);
+ continue;
+ }
+
+ if (node.Previous != null)
+ {
+ fileName = node.Previous.Value;
+ ILogFileInfo newILogFileInfo = GetLogFileInfo(fileName);
+ _logger.Debug("{0} exists\r\nOld size={1}, new size={2}", fileName, logFileInfo.OriginalLength, newILogFileInfo.Length);
+ // is the new file the same as the old buffer info?
+ if (newILogFileInfo.Length == logFileInfo.OriginalLength)
{
- _logger.Warn("File {0} not found", fileName);
- continue;
+ ReplaceBufferInfos(logFileInfo, newILogFileInfo);
+ newFileInfoList.Add(newILogFileInfo);
}
-
- if (node.Previous != null)
+ else
{
- fileName = node.Previous.Value;
- ILogFileInfo newILogFileInfo = GetLogFileInfo(fileName);
- _logger.Debug("{0} exists\r\nOld size={1}, new size={2}", fileName, logFileInfo.OriginalLength, newILogFileInfo.Length);
- // is the new file the same as the old buffer info?
- if (newILogFileInfo.Length == logFileInfo.OriginalLength)
- {
- ReplaceBufferInfos(logFileInfo, newILogFileInfo);
- newFileInfoList.Add(newILogFileInfo);
- }
- else
+ _logger.Debug("Buffer for {0} must be re-read.", fileName);
+ // not the same. so must read the rest of the list anew from the files
+ readNewILogFileInfoList.Add(newILogFileInfo);
+ while (enumerator.MoveNext())
{
- _logger.Debug("Buffer for {0} must be re-read.", fileName);
- // not the same. so must read the rest of the list anew from the files
- readNewILogFileInfoList.Add(newILogFileInfo);
- while (enumerator.MoveNext())
+ fileName = enumerator.Current.FullName;
+ node = fileNameList.Find(fileName);
+ if (node == null)
{
- fileName = enumerator.Current.FullName;
- node = fileNameList.Find(fileName);
- if (node == null)
- {
- _logger.Warn("File {0} not found", fileName);
- continue;
- }
-
- if (node.Previous != null)
- {
- fileName = node.Previous.Value;
- _logger.Debug("New name is {0}", fileName);
- readNewILogFileInfoList.Add(GetLogFileInfo(fileName));
- }
- else
- {
- _logger.Warn("No previous file for {0} found", fileName);
- }
+ _logger.Warn("File {0} not found", fileName);
+ continue;
+ }
+
+ if (node.Previous != null)
+ {
+ fileName = node.Previous.Value;
+ _logger.Debug("New name is {0}", fileName);
+ readNewILogFileInfoList.Add(GetLogFileInfo(fileName));
+ }
+ else
+ {
+ _logger.Warn("No previous file for {0} found", fileName);
}
}
}
- else
- {
- _logger.Info("{0} does not exist", fileName);
- lostILogFileInfoList.Add(logFileInfo);
+ }
+ else
+ {
+ _logger.Info("{0} does not exist", fileName);
+ lostILogFileInfoList.Add(logFileInfo);
#if DEBUG // for better overview in logfile:
- //ILogFileInfo newILogFileInfo = new ILogFileInfo(fileName);
- //ReplaceBufferInfos(ILogFileInfo, newILogFileInfo);
+ //ILogFileInfo newILogFileInfo = new ILogFileInfo(fileName);
+ //ReplaceBufferInfos(ILogFileInfo, newILogFileInfo);
#endif
- }
}
+ }
- if (lostILogFileInfoList.Count > 0)
+ if (lostILogFileInfoList.Count > 0)
+ {
+ _logger.Info("Deleting buffers for lost files");
+ foreach (ILogFileInfo ILogFileInfo in lostILogFileInfoList)
{
- _logger.Info("Deleting buffers for lost files");
- foreach (ILogFileInfo ILogFileInfo in lostILogFileInfoList)
- {
- //this.ILogFileInfoList.Remove(ILogFileInfo);
- LogBuffer lastBuffer = DeleteBuffersForInfo(ILogFileInfo, false);
- if (lastBuffer != null)
- {
- offset += lastBuffer.StartLine + lastBuffer.LineCount;
- }
- }
-
- _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite);
- _logger.Info("Adjusting StartLine values in {0} buffers by offset {1}", _bufferList.Count, offset);
- foreach (LogBuffer buffer in _bufferList)
- {
- SetNewStartLineForBuffer(buffer, buffer.StartLine - offset);
- }
-
- _lruCacheDictLock.ReleaseWriterLock();
-#if DEBUG
- if (_bufferList.Count > 0)
+ //this.ILogFileInfoList.Remove(ILogFileInfo);
+ LogBuffer lastBuffer = DeleteBuffersForInfo(ILogFileInfo, false);
+ if (lastBuffer != null)
{
- _logger.Debug("First buffer now has StartLine {0}", _bufferList[0].StartLine);
+ offset += lastBuffer.StartLine + lastBuffer.LineCount;
}
-#endif
}
- // Read anew all buffers following a buffer info that couldn't be matched with the corresponding existing file
- _logger.Info("Deleting buffers for files that must be re-read");
- foreach (ILogFileInfo ILogFileInfo in readNewILogFileInfoList)
+ _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite);
+ _logger.Info("Adjusting StartLine values in {0} buffers by offset {1}", _bufferList.Count, offset);
+ foreach (LogBuffer buffer in _bufferList)
{
- DeleteBuffersForInfo(ILogFileInfo, true);
- //this.ILogFileInfoList.Remove(ILogFileInfo);
+ SetNewStartLineForBuffer(buffer, buffer.StartLine - offset);
}
- _logger.Info("Deleting buffers for the watched file");
- DeleteBuffersForInfo(_watchedILogFileInfo, true);
- int startLine = LineCount - 1;
- _logger.Info("Re-Reading files");
- foreach (ILogFileInfo ILogFileInfo in readNewILogFileInfoList)
+ _lruCacheDictLock.ReleaseWriterLock();
+#if DEBUG
+ if (_bufferList.Count > 0)
{
- //ILogFileInfo.OpenFile();
- ReadToBufferList(ILogFileInfo, 0, LineCount);
- //this.ILogFileInfoList.Add(ILogFileInfo);
- newFileInfoList.Add(ILogFileInfo);
+ _logger.Debug("First buffer now has StartLine {0}", _bufferList[0].StartLine);
}
+#endif
+ }
- //this.watchedILogFileInfo = this.ILogFileInfoList[this.ILogFileInfoList.Count - 1];
- _logFileInfoList = newFileInfoList;
- _watchedILogFileInfo = GetLogFileInfo(_watchedILogFileInfo.FullName);
- _logFileInfoList.Add(_watchedILogFileInfo);
- _logger.Info("Reading watched file");
- ReadToBufferList(_watchedILogFileInfo, 0, LineCount);
+ // Read anew all buffers following a buffer info that couldn't be matched with the corresponding existing file
+ _logger.Info("Deleting buffers for files that must be re-read");
+ foreach (ILogFileInfo ILogFileInfo in readNewILogFileInfoList)
+ {
+ DeleteBuffersForInfo(ILogFileInfo, true);
+ //this.ILogFileInfoList.Remove(ILogFileInfo);
}
- _logger.Info("ShiftBuffers() end. offset={0}", offset);
- ReleaseBufferListWriterLock();
- return offset;
- }
+ _logger.Info("Deleting buffers for the watched file");
+ DeleteBuffersForInfo(_watchedILogFileInfo, true);
+ int startLine = LineCount - 1;
+ _logger.Info("Re-Reading files");
+ foreach (ILogFileInfo ILogFileInfo in readNewILogFileInfoList)
+ {
+ //ILogFileInfo.OpenFile();
+ ReadToBufferList(ILogFileInfo, 0, LineCount);
+ //this.ILogFileInfoList.Add(ILogFileInfo);
+ newFileInfoList.Add(ILogFileInfo);
+ }
- public ILogLine GetLogLine(int lineNum)
- {
- return GetLogLineInternal(lineNum).Result;
+ //this.watchedILogFileInfo = this.ILogFileInfoList[this.ILogFileInfoList.Count - 1];
+ _logFileInfoList = newFileInfoList;
+ _watchedILogFileInfo = GetLogFileInfo(_watchedILogFileInfo.FullName);
+ _logFileInfoList.Add(_watchedILogFileInfo);
+ _logger.Info("Reading watched file");
+ ReadToBufferList(_watchedILogFileInfo, 0, LineCount);
}
- ///
- /// Get the text content of the given line number.
- /// The actual work is done in an async thread. This method waits for thread completion for only 1 second. If the async
- /// thread has not returned, the method will return null. This is because this method is also called from GUI thread
- /// (e.g. LogWindow draw events). Under some circumstances, repeated calls to this method would lead the GUI to freeze. E.g. when
- /// trying to re-load content from disk but the file was deleted. Especially on network shares.
- ///
- ///
- /// Once the method detects a timeout it will enter a kind of 'fast fail mode'. That means all following calls will be returned with
- /// null immediately (without 1 second wait). A background call to GetLogLineInternal() will check if a result is available.
- /// If so, the 'fast fail mode' is switched off. In most cases a fail is caused by a deleted file. But it may also be caused by slow
- /// network connections. So all this effort is needed to prevent entering an endless 'fast fail mode' just because of temporary problems.
- ///
- /// line to retrieve
- ///
- public async Task GetLogLineWithWait(int lineNum)
- {
- const int WAIT_TIME = 1000;
+ _logger.Info("ShiftBuffers() end. offset={0}", offset);
+ ReleaseBufferListWriterLock();
+ return offset;
+ }
+
+ public ILogLine GetLogLine (int lineNum)
+ {
+ return GetLogLineInternal(lineNum).Result;
+ }
+
+ ///
+ /// Get the text content of the given line number.
+ /// The actual work is done in an async thread. This method waits for thread completion for only 1 second. If the async
+ /// thread has not returned, the method will return null. This is because this method is also called from GUI thread
+ /// (e.g. LogWindow draw events). Under some circumstances, repeated calls to this method would lead the GUI to freeze. E.g. when
+ /// trying to re-load content from disk but the file was deleted. Especially on network shares.
+ ///
+ ///
+ /// Once the method detects a timeout it will enter a kind of 'fast fail mode'. That means all following calls will be returned with
+ /// null immediately (without 1 second wait). A background call to GetLogLineInternal() will check if a result is available.
+ /// If so, the 'fast fail mode' is switched off. In most cases a fail is caused by a deleted file. But it may also be caused by slow
+ /// network connections. So all this effort is needed to prevent entering an endless 'fast fail mode' just because of temporary problems.
+ ///
+ /// line to retrieve
+ ///
+ public async Task GetLogLineWithWait (int lineNum)
+ {
+ const int WAIT_TIME = 1000;
- ILogLine result = null;
+ ILogLine result = null;
- if (!_isFastFailOnGetLogLine)
+ if (!_isFastFailOnGetLogLine)
+ {
+ var task = Task.Run(() => _logLineFx(lineNum));
+ if (task.Wait(WAIT_TIME))
{
- var task = Task.Run(() => _logLineFx(lineNum));
- if (task.Wait(WAIT_TIME))
- {
- result = task.Result;
- _isFastFailOnGetLogLine = false;
- }
- else
- {
- _isFastFailOnGetLogLine = true;
- _logger.Debug("No result after {0}ms. Returning .", WAIT_TIME);
- }
+ result = task.Result;
+ _isFastFailOnGetLogLine = false;
}
else
{
- _logger.Debug("Fast failing GetLogLine()");
- if (!_isFailModeCheckCallPending)
- {
- _isFailModeCheckCallPending = true;
- var logLine = await _logLineFx(lineNum);
- GetLineFinishedCallback(logLine);
- }
+ _isFastFailOnGetLogLine = true;
+ _logger.Debug("No result after {0}ms. Returning .", WAIT_TIME);
}
-
- return result;
}
-
- ///
- /// Returns the file name of the actual file for the given line. Needed for MultiFile.
- ///
- ///
- ///
- public string GetLogFileNameForLine(int lineNum)
+ else
{
- AcquireBufferListReaderLock();
- LogBuffer logBuffer = GetBufferForLine(lineNum);
- string fileName = logBuffer?.FileInfo.FullName;
- ReleaseBufferListReaderLock();
- return fileName;
+ _logger.Debug("Fast failing GetLogLine()");
+ if (!_isFailModeCheckCallPending)
+ {
+ _isFailModeCheckCallPending = true;
+ var logLine = await _logLineFx(lineNum);
+ GetLineFinishedCallback(logLine);
+ }
}
- ///
- /// Returns the ILogFileInfo for the actual file for the given line. Needed for MultiFile.
- ///
- ///
- ///
- public ILogFileInfo GetLogFileInfoForLine(int lineNum)
- {
- AcquireBufferListReaderLock();
- LogBuffer logBuffer = GetBufferForLine(lineNum);
- ILogFileInfo info = logBuffer?.FileInfo;
- ReleaseBufferListReaderLock();
- return info;
- }
+ return result;
+ }
+
+ ///
+ /// Returns the file name of the actual file for the given line. Needed for MultiFile.
+ ///
+ ///
+ ///
+ public string GetLogFileNameForLine (int lineNum)
+ {
+ AcquireBufferListReaderLock();
+ LogBuffer logBuffer = GetBufferForLine(lineNum);
+ string fileName = logBuffer?.FileInfo.FullName;
+ ReleaseBufferListReaderLock();
+ return fileName;
+ }
+
+ ///
+ /// Returns the ILogFileInfo for the actual file for the given line. Needed for MultiFile.
+ ///
+ ///
+ ///
+ public ILogFileInfo GetLogFileInfoForLine (int lineNum)
+ {
+ AcquireBufferListReaderLock();
+ LogBuffer logBuffer = GetBufferForLine(lineNum);
+ ILogFileInfo info = logBuffer?.FileInfo;
+ ReleaseBufferListReaderLock();
+ return info;
+ }
- ///
- /// Returns the line number (starting from the given number) where the next multi file
- /// starts.
- ///
- ///
- ///
- public int GetNextMultiFileLine(int lineNum)
+ ///
+ /// Returns the line number (starting from the given number) where the next multi file
+ /// starts.
+ ///
+ ///
+ ///
+ public int GetNextMultiFileLine (int lineNum)
+ {
+ int result = -1;
+ AcquireBufferListReaderLock();
+ LogBuffer logBuffer = GetBufferForLine(lineNum);
+ if (logBuffer != null)
{
- int result = -1;
- AcquireBufferListReaderLock();
- LogBuffer logBuffer = GetBufferForLine(lineNum);
- if (logBuffer != null)
+ int index = _bufferList.IndexOf(logBuffer);
+ if (index != -1)
{
- int index = _bufferList.IndexOf(logBuffer);
- if (index != -1)
+ for (int i = index; i < _bufferList.Count; ++i)
{
- for (int i = index; i < _bufferList.Count; ++i)
+ if (_bufferList[i].FileInfo != logBuffer.FileInfo)
{
- if (_bufferList[i].FileInfo != logBuffer.FileInfo)
- {
- result = _bufferList[i].StartLine;
- break;
- }
+ result = _bufferList[i].StartLine;
+ break;
}
}
}
-
- ReleaseBufferListReaderLock();
- return result;
}
- public int GetPrevMultiFileLine(int lineNum)
+ ReleaseBufferListReaderLock();
+ return result;
+ }
+
+ public int GetPrevMultiFileLine (int lineNum)
+ {
+ int result = -1;
+ AcquireBufferListReaderLock();
+ LogBuffer logBuffer = GetBufferForLine(lineNum);
+ if (logBuffer != null)
{
- int result = -1;
- AcquireBufferListReaderLock();
- LogBuffer logBuffer = GetBufferForLine(lineNum);
- if (logBuffer != null)
+ int index = _bufferList.IndexOf(logBuffer);
+ if (index != -1)
{
- int index = _bufferList.IndexOf(logBuffer);
- if (index != -1)
+ for (int i = index; i >= 0; --i)
{
- for (int i = index; i >= 0; --i)
+ if (_bufferList[i].FileInfo != logBuffer.FileInfo)
{
- if (_bufferList[i].FileInfo != logBuffer.FileInfo)
- {
- result = _bufferList[i].StartLine + _bufferList[i].LineCount;
- break;
- }
+ result = _bufferList[i].StartLine + _bufferList[i].LineCount;
+ break;
}
}
}
+ }
- ReleaseBufferListReaderLock();
- return result;
- }
-
- ///
- /// Returns the actual line number in the file for the given 'virtual line num'.
- /// This is needed for multi file mode. 'Virtual' means that the given line num is a line
- /// number in the collections of the files currently viewed together in multi file mode as one large virtual file.
- /// This method finds the real file for the line number and maps the line number to the correct position
- /// in that file. This is needed when launching external tools to provide correct line number arguments.
- ///
- ///
- ///
- public int GetRealLineNumForVirtualLineNum(int lineNum)
- {
- AcquireBufferListReaderLock();
- LogBuffer logBuffer = GetBufferForLine(lineNum);
- int result = -1;
+ ReleaseBufferListReaderLock();
+ return result;
+ }
+
+ ///
+ /// Returns the actual line number in the file for the given 'virtual line num'.
+ /// This is needed for multi file mode. 'Virtual' means that the given line num is a line
+ /// number in the collections of the files currently viewed together in multi file mode as one large virtual file.
+ /// This method finds the real file for the line number and maps the line number to the correct position
+ /// in that file. This is needed when launching external tools to provide correct line number arguments.
+ ///
+ ///
+ ///
+ public int GetRealLineNumForVirtualLineNum (int lineNum)
+ {
+ AcquireBufferListReaderLock();
+ LogBuffer logBuffer = GetBufferForLine(lineNum);
+ int result = -1;
+ if (logBuffer != null)
+ {
+ logBuffer = GetFirstBufferForFileByLogBuffer(logBuffer);
if (logBuffer != null)
{
- logBuffer = GetFirstBufferForFileByLogBuffer(logBuffer);
- if (logBuffer != null)
- {
- result = lineNum - logBuffer.StartLine;
- }
+ result = lineNum - logBuffer.StartLine;
}
-
- ReleaseBufferListReaderLock();
- return result;
}
- public void StartMonitoring()
- {
- _logger.Info("startMonitoring()");
- _monitorTask = Task.Run(MonitorThreadProc, cts.Token);
- _shouldStop = false;
- }
+ ReleaseBufferListReaderLock();
+ return result;
+ }
- public void StopMonitoring()
- {
- _logger.Info("stopMonitoring()");
- _shouldStop = true;
+ public void StartMonitoring ()
+ {
+ _logger.Info("startMonitoring()");
+ _monitorTask = Task.Run(MonitorThreadProc, cts.Token);
+ _shouldStop = false;
+ }
+
+ public void StopMonitoring ()
+ {
+ _logger.Info("stopMonitoring()");
+ _shouldStop = true;
- Thread.Sleep(_watchedILogFileInfo.PollInterval); // leave time for the threads to stop by themselves
+ Thread.Sleep(_watchedILogFileInfo.PollInterval); // leave time for the threads to stop by themselves
- if (_monitorTask != null)
+ if (_monitorTask != null)
+ {
+ if (_monitorTask.Status == TaskStatus.Running) // if thread has not finished, abort it
{
- if (_monitorTask.Status == TaskStatus.Running) // if thread has not finished, abort it
- {
- cts.Cancel();
- }
+ cts.Cancel();
}
+ }
- if (_garbageCollectorTask.IsCanceled == false)
+ if (_garbageCollectorTask.IsCanceled == false)
+ {
+ if (_garbageCollectorTask.Status == TaskStatus.Running) // if thread has not finished, abort it
{
- if (_garbageCollectorTask.Status == TaskStatus.Running) // if thread has not finished, abort it
- {
- cts.Cancel();
- }
+ cts.Cancel();
}
-
- //this.loadThread = null;
- //_monitorThread = null;
- //_garbageCollectorThread = null; // preventive call
- CloseFiles();
}
- ///
- /// calls stopMonitoring() in a background thread and returns to the caller immediately.
- /// This is useful for a fast responding GUI (e.g. when closing a file tab)
- ///
- public void StopMonitoringAsync()
- {
- Task task = Task.Run(StopMonitoring);
+ //this.loadThread = null;
+ //_monitorThread = null;
+ //_garbageCollectorThread = null; // preventive call
+ CloseFiles();
+ }
- //Thread stopperThread = new(new ThreadStart(StopMonitoring))
- //{
- // IsBackground = true
- //};
- //stopperThread.Start();
- }
+ ///
+ /// calls stopMonitoring() in a background thread and returns to the caller immediately.
+ /// This is useful for a fast responding GUI (e.g. when closing a file tab)
+ ///
+ public void StopMonitoringAsync ()
+ {
+ Task task = Task.Run(StopMonitoring);
+
+ //Thread stopperThread = new(new ThreadStart(StopMonitoring))
+ //{
+ // IsBackground = true
+ //};
+ //stopperThread.Start();
+ }
- ///
- /// Deletes all buffer lines and disposes their content. Use only when the LogfileReader
- /// is about to be closed!
- ///
- public void DeleteAllContent()
+ ///
+ /// Deletes all buffer lines and disposes their content. Use only when the LogfileReader
+ /// is about to be closed!
+ ///
+ public void DeleteAllContent ()
+ {
+ if (_contentDeleted)
{
- if (_contentDeleted)
- {
- _logger.Debug("Buffers for {0} already deleted.", Util.GetNameFromPath(_fileName));
- return;
- }
+ _logger.Debug("Buffers for {0} already deleted.", Util.GetNameFromPath(_fileName));
+ return;
+ }
- _logger.Info("Deleting all log buffers for {0}. Used mem: {1:N0}", Util.GetNameFromPath(_fileName), GC.GetTotalMemory(true)); //TODO [Z] uh GC collect calls creepy
- AcquireBufferListWriterLock();
- _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite);
- _disposeLock.AcquireWriterLock(Timeout.Infinite);
+ _logger.Info("Deleting all log buffers for {0}. Used mem: {1:N0}", Util.GetNameFromPath(_fileName), GC.GetTotalMemory(true)); //TODO [Z] uh GC collect calls creepy
+ AcquireBufferListWriterLock();
+ _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite);
+ _disposeLock.AcquireWriterLock(Timeout.Infinite);
- foreach (LogBuffer logBuffer in _bufferList)
+ foreach (LogBuffer logBuffer in _bufferList)
+ {
+ if (!logBuffer.IsDisposed)
{
- if (!logBuffer.IsDisposed)
- {
- logBuffer.DisposeContent();
- }
+ logBuffer.DisposeContent();
}
+ }
- _lruCacheDict.Clear();
- _bufferList.Clear();
+ _lruCacheDict.Clear();
+ _bufferList.Clear();
- _disposeLock.ReleaseWriterLock();
- _lruCacheDictLock.ReleaseWriterLock();
- ReleaseBufferListWriterLock();
- GC.Collect();
- _contentDeleted = true;
- _logger.Info("Deleting complete. Used mem: {0:N0}", GC.GetTotalMemory(true)); //TODO [Z] uh GC collect calls creepy
- }
+ _disposeLock.ReleaseWriterLock();
+ _lruCacheDictLock.ReleaseWriterLock();
+ ReleaseBufferListWriterLock();
+ GC.Collect();
+ _contentDeleted = true;
+ _logger.Info("Deleting complete. Used mem: {0:N0}", GC.GetTotalMemory(true)); //TODO [Z] uh GC collect calls creepy
+ }
- ///
- /// Explicit change the encoding.
- ///
- ///
- public void ChangeEncoding(Encoding encoding)
- {
- CurrentEncoding = encoding;
- EncodingOptions.Encoding = encoding;
- ResetBufferCache();
- ClearLru();
- }
+ ///
+ /// Explicit change the encoding.
+ ///
+ ///
+ public void ChangeEncoding (Encoding encoding)
+ {
+ CurrentEncoding = encoding;
+ EncodingOptions.Encoding = encoding;
+ ResetBufferCache();
+ ClearLru();
+ }
- ///
- /// For unit tests only.
- ///
- ///
- public IList GetLogFileInfoList()
- {
- return _logFileInfoList;
- }
+ ///
+ /// For unit tests only.
+ ///
+ ///
+ public IList GetLogFileInfoList ()
+ {
+ return _logFileInfoList;
+ }
- ///
- /// For unit tests only
- ///
- ///
- public IList GetBufferList()
- {
- return _bufferList;
- }
+ ///
+ /// For unit tests only
+ ///
+ ///
+ public IList GetBufferList ()
+ {
+ return _bufferList;
+ }
- #endregion
+ #endregion
- #region Internals
+ #region Internals
#if DEBUG
- public void LogBufferInfoForLine(int lineNum)
+ public void LogBufferInfoForLine (int lineNum)
+ {
+ AcquireBufferListReaderLock();
+ LogBuffer buffer = GetBufferForLine(lineNum);
+ if (buffer == null)
{
- AcquireBufferListReaderLock();
- LogBuffer buffer = GetBufferForLine(lineNum);
- if (buffer == null)
- {
- ReleaseBufferListReaderLock();
- _logger.Error("Cannot find buffer for line {0}, file: {1}{2}", lineNum, _fileName, IsMultiFile ? " (MultiFile)" : "");
- return;
- }
-
- _logger.Info("-----------------------------------");
- _disposeLock.AcquireReaderLock(Timeout.Infinite);
- _logger.Info("Buffer info for line {0}", lineNum);
- DumpBufferInfos(buffer);
- _logger.Info("File pos for current line: {0}", buffer.GetFilePosForLineOfBlock(lineNum - buffer.StartLine));
- _disposeLock.ReleaseReaderLock();
- _logger.Info("-----------------------------------");
ReleaseBufferListReaderLock();
- }
+ _logger.Error("Cannot find buffer for line {0}, file: {1}{2}", lineNum, _fileName, IsMultiFile ? " (MultiFile)" : "");
+ return;
+ }
+
+ _logger.Info("-----------------------------------");
+ _disposeLock.AcquireReaderLock(Timeout.Infinite);
+ _logger.Info("Buffer info for line {0}", lineNum);
+ DumpBufferInfos(buffer);
+ _logger.Info("File pos for current line: {0}", buffer.GetFilePosForLineOfBlock(lineNum - buffer.StartLine));
+ _disposeLock.ReleaseReaderLock();
+ _logger.Info("-----------------------------------");
+ ReleaseBufferListReaderLock();
+ }
#endif
#if DEBUG
- public void LogBufferDiagnostic()
- {
- _logger.Info("-------- Buffer diagnostics -------");
- _lruCacheDictLock.AcquireReaderLock(Timeout.Infinite);
- int cacheCount = _lruCacheDict.Count;
- _logger.Info("LRU entries: {0}", cacheCount);
- _lruCacheDictLock.ReleaseReaderLock();
-
- AcquireBufferListReaderLock();
- _logger.Info("File: {0}\r\nBuffer count: {1}\r\nDisposed buffers: {2}", _fileName, _bufferList.Count, _bufferList.Count - cacheCount);
- int lineNum = 0;
- long disposeSum = 0;
- long maxDispose = 0;
- long minDispose = int.MaxValue;
- for (int i = 0; i < _bufferList.Count; ++i)
+ public void LogBufferDiagnostic ()
+ {
+ _logger.Info("-------- Buffer diagnostics -------");
+ _lruCacheDictLock.AcquireReaderLock(Timeout.Infinite);
+ int cacheCount = _lruCacheDict.Count;
+ _logger.Info("LRU entries: {0}", cacheCount);
+ _lruCacheDictLock.ReleaseReaderLock();
+
+ AcquireBufferListReaderLock();
+ _logger.Info("File: {0}\r\nBuffer count: {1}\r\nDisposed buffers: {2}", _fileName, _bufferList.Count, _bufferList.Count - cacheCount);
+ int lineNum = 0;
+ long disposeSum = 0;
+ long maxDispose = 0;
+ long minDispose = int.MaxValue;
+ for (int i = 0; i < _bufferList.Count; ++i)
+ {
+ LogBuffer buffer = _bufferList[i];
+ _disposeLock.AcquireReaderLock(Timeout.Infinite);
+ if (buffer.StartLine != lineNum)
{
- LogBuffer buffer = _bufferList[i];
- _disposeLock.AcquireReaderLock(Timeout.Infinite);
- if (buffer.StartLine != lineNum)
- {
- _logger.Error("Start line of buffer is: {0}, expected: {1}", buffer.StartLine, lineNum);
- _logger.Info("Info of buffer follows:");
- DumpBufferInfos(buffer);
- }
-
- lineNum += buffer.LineCount;
- disposeSum += buffer.DisposeCount;
- maxDispose = Math.Max(maxDispose, buffer.DisposeCount);
- minDispose = Math.Min(minDispose, buffer.DisposeCount);
- _disposeLock.ReleaseReaderLock();
+ _logger.Error("Start line of buffer is: {0}, expected: {1}", buffer.StartLine, lineNum);
+ _logger.Info("Info of buffer follows:");
+ DumpBufferInfos(buffer);
}
- ReleaseBufferListReaderLock();
- _logger.Info("Dispose count sum is: {0}\r\nMin dispose count is: {1}\r\nMax dispose count is: {2}\r\n-----------------------------------", disposeSum, minDispose, maxDispose);
+ lineNum += buffer.LineCount;
+ disposeSum += buffer.DisposeCount;
+ maxDispose = Math.Max(maxDispose, buffer.DisposeCount);
+ minDispose = Math.Min(minDispose, buffer.DisposeCount);
+ _disposeLock.ReleaseReaderLock();
}
+ ReleaseBufferListReaderLock();
+ _logger.Info("Dispose count sum is: {0}\r\nMin dispose count is: {1}\r\nMax dispose count is: {2}\r\n-----------------------------------", disposeSum, minDispose, maxDispose);
+ }
+
#endif
- #endregion
+ #endregion
+
+ #region Private Methods
- #region Private Methods
+ private ILogFileInfo AddFile (string fileName)
+ {
+ _logger.Info("Adding file to ILogFileInfoList: " + fileName);
+ ILogFileInfo info = GetLogFileInfo(fileName);
+ _logFileInfoList.Add(info);
+ return info;
+ }
- private ILogFileInfo AddFile(string fileName)
+ private Task GetLogLineInternal (int lineNum)
+ {
+ if (_isDeleted)
{
- _logger.Info("Adding file to ILogFileInfoList: " + fileName);
- ILogFileInfo info = GetLogFileInfo(fileName);
- _logFileInfoList.Add(info);
- return info;
+ _logger.Debug("Returning null for line {0} because file is deleted.", lineNum);
+
+ // fast fail if dead file was detected. Prevents repeated lags in GUI thread caused by callbacks from control (e.g. repaint)
+ return null;
}
- private Task GetLogLineInternal(int lineNum)
+ AcquireBufferListReaderLock();
+ LogBuffer logBuffer = GetBufferForLine(lineNum);
+ if (logBuffer == null)
{
- if (_isDeleted)
- {
- _logger.Debug("Returning null for line {0} because file is deleted.", lineNum);
-
- // fast fail if dead file was detected. Prevents repeated lags in GUI thread caused by callbacks from control (e.g. repaint)
- return null;
- }
+ ReleaseBufferListReaderLock();
+ _logger.Error("Cannot find buffer for line {0}, file: {1}{2}", lineNum, _fileName, IsMultiFile ? " (MultiFile)" : "");
+ return null;
+ }
- AcquireBufferListReaderLock();
- LogBuffer logBuffer = GetBufferForLine(lineNum);
- if (logBuffer == null)
+ // disposeLock prevents that the garbage collector is disposing just in the moment we use the buffer
+ _disposeLock.AcquireReaderLock(Timeout.Infinite);
+ if (logBuffer.IsDisposed)
+ {
+ LockCookie cookie = _disposeLock.UpgradeToWriterLock(Timeout.Infinite);
+ lock (logBuffer.FileInfo)
{
- ReleaseBufferListReaderLock();
- _logger.Error("Cannot find buffer for line {0}, file: {1}{2}", lineNum, _fileName, IsMultiFile ? " (MultiFile)" : "");
- return null;
+ ReReadBuffer(logBuffer);
}
- // disposeLock prevents that the garbage collector is disposing just in the moment we use the buffer
- _disposeLock.AcquireReaderLock(Timeout.Infinite);
- if (logBuffer.IsDisposed)
- {
- LockCookie cookie = _disposeLock.UpgradeToWriterLock(Timeout.Infinite);
- lock (logBuffer.FileInfo)
- {
- ReReadBuffer(logBuffer);
- }
+ _disposeLock.DowngradeFromWriterLock(ref cookie);
+ }
- _disposeLock.DowngradeFromWriterLock(ref cookie);
- }
+ ILogLine line = logBuffer.GetLineOfBlock(lineNum - logBuffer.StartLine);
+ _disposeLock.ReleaseReaderLock();
+ ReleaseBufferListReaderLock();
- ILogLine line = logBuffer.GetLineOfBlock(lineNum - logBuffer.StartLine);
- _disposeLock.ReleaseReaderLock();
- ReleaseBufferListReaderLock();
+ return Task.FromResult(line);
+ }
- return Task.FromResult(line);
- }
+ private void InitLruBuffers ()
+ {
+ _bufferList = [];
+ _bufferLru = new List(_MAX_BUFFERS + 1);
+ //this.lruDict = new Dictionary(this.MAX_BUFFERS + 1); // key=startline, value = index in bufferLru
+ _lruCacheDict = new Dictionary(_MAX_BUFFERS + 1);
+ _lruCacheDictLock = new ReaderWriterLock();
+ _bufferListLock = new ReaderWriterLock();
+ _disposeLock = new ReaderWriterLock();
+ }
- private void InitLruBuffers()
- {
- _bufferList = [];
- _bufferLru = new List(_MAX_BUFFERS + 1);
- //this.lruDict = new Dictionary(this.MAX_BUFFERS + 1); // key=startline, value = index in bufferLru
- _lruCacheDict = new Dictionary(_MAX_BUFFERS + 1);
- _lruCacheDictLock = new ReaderWriterLock();
- _bufferListLock = new ReaderWriterLock();
- _disposeLock = new ReaderWriterLock();
- }
+ private void StartGCThread ()
+ {
+ _garbageCollectorTask = Task.Run(GarbageCollectorThreadProc, cts.Token);
+ //_garbageCollectorThread = new Thread(new ThreadStart(GarbageCollectorThreadProc));
+ //_garbageCollectorThread.IsBackground = true;
+ //_garbageCollectorThread.Start();
+ }
- private void StartGCThread()
- {
- _garbageCollectorTask = Task.Run(GarbageCollectorThreadProc, cts.Token);
- //_garbageCollectorThread = new Thread(new ThreadStart(GarbageCollectorThreadProc));
- //_garbageCollectorThread.IsBackground = true;
- //_garbageCollectorThread.Start();
- }
+ private void ResetBufferCache ()
+ {
+ FileSize = 0;
+ LineCount = 0;
+ //this.lastReturnedLine = "";
+ //this.lastReturnedLineNum = -1;
+ //this.lastReturnedLineNumForBuffer = -1;
+ }
- private void ResetBufferCache()
- {
- FileSize = 0;
- LineCount = 0;
- //this.lastReturnedLine = "";
- //this.lastReturnedLineNum = -1;
- //this.lastReturnedLineNumForBuffer = -1;
- }
+ private void CloseFiles ()
+ {
+ //foreach (ILogFileInfo info in this.ILogFileInfoList)
+ //{
+ // info.CloseFile();
+ //}
+ FileSize = 0;
+ LineCount = 0;
+ //this.lastReturnedLine = "";
+ //this.lastReturnedLineNum = -1;
+ //this.lastReturnedLineNumForBuffer = -1;
+ }
- private void CloseFiles()
- {
- //foreach (ILogFileInfo info in this.ILogFileInfoList)
- //{
- // info.CloseFile();
- //}
- FileSize = 0;
- LineCount = 0;
- //this.lastReturnedLine = "";
- //this.lastReturnedLineNum = -1;
- //this.lastReturnedLineNumForBuffer = -1;
- }
+ private ILogFileInfo GetLogFileInfo (string fileNameOrUri) //TODO: I changed to static
+ {
+ //TODO this must be fixed and should be given to the logfilereader not just called (https://github.com/LogExperts/LogExpert/issues/402)
+ IFileSystemPlugin fs = _pluginRegistry.FindFileSystemForUri(fileNameOrUri) ?? throw new LogFileException("No file system plugin found for " + fileNameOrUri);
+ ILogFileInfo logFileInfo = fs.GetLogfileInfo(fileNameOrUri);
+ return logFileInfo ?? throw new LogFileException("Cannot find " + fileNameOrUri);
+ }
- private ILogFileInfo GetLogFileInfo(string fileNameOrUri) //TODO: I changed to static
+ private void ReplaceBufferInfos (ILogFileInfo oldLogFileInfo, ILogFileInfo newLogFileInfo)
+ {
+ _logger.Debug("ReplaceBufferInfos() " + oldLogFileInfo.FullName + " -> " + newLogFileInfo.FullName);
+ AcquireBufferListReaderLock();
+ foreach (LogBuffer buffer in _bufferList)
{
- //TODO this must be fixed and should be given to the logfilereader not just called
- IFileSystemPlugin fs = _pluginRegistry.FindFileSystemForUri(fileNameOrUri) ?? throw new LogFileException("No file system plugin found for " + fileNameOrUri);
- ILogFileInfo logFileInfo = fs.GetLogfileInfo(fileNameOrUri);
- return logFileInfo ?? throw new LogFileException("Cannot find " + fileNameOrUri);
+ if (buffer.FileInfo == oldLogFileInfo)
+ {
+ _logger.Debug("Buffer with startLine={0}, lineCount={1}, filePos={2}, size={3} gets new filename {4}", buffer.StartLine, buffer.LineCount, buffer.StartPos, buffer.Size, newLogFileInfo.FullName);
+ buffer.FileInfo = newLogFileInfo;
+ }
}
- private void ReplaceBufferInfos(ILogFileInfo oldLogFileInfo, ILogFileInfo newLogFileInfo)
+ ReleaseBufferListReaderLock();
+ }
+
+ private LogBuffer DeleteBuffersForInfo (ILogFileInfo ILogFileInfo, bool matchNamesOnly)
+ {
+ _logger.Info("Deleting buffers for file {0}", ILogFileInfo.FullName);
+ LogBuffer lastRemovedBuffer = null;
+ IList deleteList = [];
+ AcquireBufferListWriterLock();
+ _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite);
+ if (matchNamesOnly)
{
- _logger.Debug("ReplaceBufferInfos() " + oldLogFileInfo.FullName + " -> " + newLogFileInfo.FullName);
- AcquireBufferListReaderLock();
foreach (LogBuffer buffer in _bufferList)
{
- if (buffer.FileInfo == oldLogFileInfo)
+ if (buffer.FileInfo.FullName.ToLower().Equals(ILogFileInfo.FullName.ToLower()))
{
- _logger.Debug("Buffer with startLine={0}, lineCount={1}, filePos={2}, size={3} gets new filename {4}", buffer.StartLine, buffer.LineCount, buffer.StartPos, buffer.Size, newLogFileInfo.FullName);
- buffer.FileInfo = newLogFileInfo;
+ lastRemovedBuffer = buffer;
+ deleteList.Add(buffer);
}
}
-
- ReleaseBufferListReaderLock();
}
-
- private LogBuffer DeleteBuffersForInfo(ILogFileInfo ILogFileInfo, bool matchNamesOnly)
+ else
{
- _logger.Info("Deleting buffers for file {0}", ILogFileInfo.FullName);
- LogBuffer lastRemovedBuffer = null;
- IList deleteList = [];
- AcquireBufferListWriterLock();
- _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite);
- if (matchNamesOnly)
- {
- foreach (LogBuffer buffer in _bufferList)
- {
- if (buffer.FileInfo.FullName.ToLower().Equals(ILogFileInfo.FullName.ToLower()))
- {
- lastRemovedBuffer = buffer;
- deleteList.Add(buffer);
- }
- }
- }
- else
+ foreach (LogBuffer buffer in _bufferList)
{
- foreach (LogBuffer buffer in _bufferList)
+ if (buffer.FileInfo == ILogFileInfo)
{
- if (buffer.FileInfo == ILogFileInfo)
- {
- lastRemovedBuffer = buffer;
- deleteList.Add(buffer);
- }
+ lastRemovedBuffer = buffer;
+ deleteList.Add(buffer);
}
}
+ }
- foreach (LogBuffer buffer in deleteList)
- {
- RemoveFromBufferList(buffer);
- }
-
- _lruCacheDictLock.ReleaseWriterLock();
- ReleaseBufferListWriterLock();
- if (lastRemovedBuffer == null)
- {
- _logger.Info("lastRemovedBuffer is null");
- }
- else
- {
- _logger.Info("lastRemovedBuffer: startLine={0}", lastRemovedBuffer.StartLine);
- }
-
- return lastRemovedBuffer;
+ foreach (LogBuffer buffer in deleteList)
+ {
+ RemoveFromBufferList(buffer);
}
- ///
- /// The caller must have writer locks for lruCache and buffer list!
- ///
- ///
- private void RemoveFromBufferList(LogBuffer buffer)
+ _lruCacheDictLock.ReleaseWriterLock();
+ ReleaseBufferListWriterLock();
+ if (lastRemovedBuffer == null)
+ {
+ _logger.Info("lastRemovedBuffer is null");
+ }
+ else
{
- Util.AssertTrue(_lruCacheDictLock.IsWriterLockHeld, "No writer lock for lru cache");
- Util.AssertTrue(_bufferListLock.IsWriterLockHeld, "No writer lock for buffer list");
- _lruCacheDict.Remove(buffer.StartLine);
- _bufferList.Remove(buffer);
+ _logger.Info("lastRemovedBuffer: startLine={0}", lastRemovedBuffer.StartLine);
}
- private void ReadToBufferList(ILogFileInfo logFileInfo, long filePos, int startLine)
+ return lastRemovedBuffer;
+ }
+
+ ///
+ /// The caller must have writer locks for lruCache and buffer list!
+ ///
+ ///
+ private void RemoveFromBufferList (LogBuffer buffer)
+ {
+ Util.AssertTrue(_lruCacheDictLock.IsWriterLockHeld, "No writer lock for lru cache");
+ Util.AssertTrue(_bufferListLock.IsWriterLockHeld, "No writer lock for buffer list");
+ _lruCacheDict.Remove(buffer.StartLine);
+ _bufferList.Remove(buffer);
+ }
+
+ private void ReadToBufferList (ILogFileInfo logFileInfo, long filePos, int startLine)
+ {
+ try
{
+ using Stream fileStream = logFileInfo.OpenStream();
try
{
- using Stream fileStream = logFileInfo.OpenStream();
- try
+ using ILogStreamReader reader = GetLogStreamReader(fileStream, EncodingOptions, UseNewReader);
+ reader.Position = filePos;
+ _fileLength = logFileInfo.Length;
+
+ int lineNum = startLine;
+ LogBuffer logBuffer;
+ AcquireBufferListReaderLock();
+ if (_bufferList.Count == 0)
+ {
+ logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER);
+ logBuffer.StartLine = startLine;
+ logBuffer.StartPos = filePos;
+ LockCookie cookie = UpgradeBufferListLockToWriter();
+ AddBufferToList(logBuffer);
+ DowngradeBufferListLockFromWriter(ref cookie);
+ }
+ else
{
- using ILogStreamReader reader = GetLogStreamReader(fileStream, EncodingOptions, UseNewReader);
- reader.Position = filePos;
- _fileLength = logFileInfo.Length;
-
- int lineNum = startLine;
- LogBuffer logBuffer;
- AcquireBufferListReaderLock();
- if (_bufferList.Count == 0)
+ logBuffer = _bufferList[_bufferList.Count - 1];
+
+ if (!logBuffer.FileInfo.FullName.Equals(logFileInfo.FullName))
{
logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER);
logBuffer.StartLine = startLine;
@@ -943,891 +958,877 @@ private void ReadToBufferList(ILogFileInfo logFileInfo, long filePos, int startL
AddBufferToList(logBuffer);
DowngradeBufferListLockFromWriter(ref cookie);
}
- else
+
+ _disposeLock.AcquireReaderLock(Timeout.Infinite);
+ if (logBuffer.IsDisposed)
{
- logBuffer = _bufferList[_bufferList.Count - 1];
+ LockCookie cookie = _disposeLock.UpgradeToWriterLock(Timeout.Infinite);
+ ReReadBuffer(logBuffer);
+ _disposeLock.DowngradeFromWriterLock(ref cookie);
+ }
- if (!logBuffer.FileInfo.FullName.Equals(logFileInfo.FullName))
- {
- logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER);
- logBuffer.StartLine = startLine;
- logBuffer.StartPos = filePos;
- LockCookie cookie = UpgradeBufferListLockToWriter();
- AddBufferToList(logBuffer);
- DowngradeBufferListLockFromWriter(ref cookie);
- }
+ _disposeLock.ReleaseReaderLock();
+ }
- _disposeLock.AcquireReaderLock(Timeout.Infinite);
- if (logBuffer.IsDisposed)
- {
- LockCookie cookie = _disposeLock.UpgradeToWriterLock(Timeout.Infinite);
- ReReadBuffer(logBuffer);
- _disposeLock.DowngradeFromWriterLock(ref cookie);
- }
+ Monitor.Enter(logBuffer); // Lock the buffer
+ ReleaseBufferListReaderLock();
+ int lineCount = logBuffer.LineCount;
+ int droppedLines = logBuffer.PrevBuffersDroppedLinesSum;
+ filePos = reader.Position;
- _disposeLock.ReleaseReaderLock();
+ while (ReadLine(reader, logBuffer.StartLine + logBuffer.LineCount, logBuffer.StartLine + logBuffer.LineCount + droppedLines, out var line))
+ {
+ LogLine logLine = new();
+ if (_shouldStop)
+ {
+ Monitor.Exit(logBuffer);
+ return;
}
- Monitor.Enter(logBuffer); // Lock the buffer
- ReleaseBufferListReaderLock();
- int lineCount = logBuffer.LineCount;
- int droppedLines = logBuffer.PrevBuffersDroppedLinesSum;
- filePos = reader.Position;
-
- while (ReadLine(reader, logBuffer.StartLine + logBuffer.LineCount, logBuffer.StartLine + logBuffer.LineCount + droppedLines, out var line))
+ if (line == null)
{
- LogLine logLine = new();
- if (_shouldStop)
- {
- Monitor.Exit(logBuffer);
- return;
- }
-
- if (line == null)
- {
- logBuffer.DroppedLinesCount += 1;
- droppedLines++;
- continue;
- }
-
- lineCount++;
- if (lineCount > _MAX_LINES_PER_BUFFER && reader.IsBufferComplete)
- {
- OnLoadFile(new LoadFileEventArgs(logFileInfo.FullName, filePos, false, logFileInfo.Length, false));
-
- Monitor.Exit(logBuffer);
- logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER);
- Monitor.Enter(logBuffer);
- logBuffer.StartLine = lineNum;
- logBuffer.StartPos = filePos;
- logBuffer.PrevBuffersDroppedLinesSum = droppedLines;
- AcquireBufferListWriterLock();
- AddBufferToList(logBuffer);
- ReleaseBufferListWriterLock();
- lineCount = 1;
- }
-
- logLine.FullLine = line;
- logLine.LineNumber = logBuffer.StartLine + logBuffer.LineCount;
-
- logBuffer.AddLine(logLine, filePos);
- filePos = reader.Position;
- lineNum++;
+ logBuffer.DroppedLinesCount += 1;
+ droppedLines++;
+ continue;
}
- logBuffer.Size = filePos - logBuffer.StartPos;
- Monitor.Exit(logBuffer);
- _isLineCountDirty = true;
- FileSize = reader.Position;
- CurrentEncoding = reader.Encoding; // Reader may have detected another encoding
- if (!_shouldStop)
+ lineCount++;
+ if (lineCount > _MAX_LINES_PER_BUFFER && reader.IsBufferComplete)
{
- OnLoadFile(new LoadFileEventArgs(logFileInfo.FullName, filePos, true, _fileLength, false));
- // Fire "Ready" Event
+ OnLoadFile(new LoadFileEventArgs(logFileInfo.FullName, filePos, false, logFileInfo.Length, false));
+
+ Monitor.Exit(logBuffer);
+ logBuffer = new LogBuffer(logFileInfo, _MAX_LINES_PER_BUFFER);
+ Monitor.Enter(logBuffer);
+ logBuffer.StartLine = lineNum;
+ logBuffer.StartPos = filePos;
+ logBuffer.PrevBuffersDroppedLinesSum = droppedLines;
+ AcquireBufferListWriterLock();
+ AddBufferToList(logBuffer);
+ ReleaseBufferListWriterLock();
+ lineCount = 1;
}
+
+ logLine.FullLine = line;
+ logLine.LineNumber = logBuffer.StartLine + logBuffer.LineCount;
+
+ logBuffer.AddLine(logLine, filePos);
+ filePos = reader.Position;
+ lineNum++;
}
- catch (IOException ioex)
+
+ logBuffer.Size = filePos - logBuffer.StartPos;
+ Monitor.Exit(logBuffer);
+ _isLineCountDirty = true;
+ FileSize = reader.Position;
+ CurrentEncoding = reader.Encoding; // Reader may have detected another encoding
+ if (!_shouldStop)
{
- _logger.Warn(ioex);
+ OnLoadFile(new LoadFileEventArgs(logFileInfo.FullName, filePos, true, _fileLength, false));
+ // Fire "Ready" Event
}
}
- catch (IOException fe)
+ catch (IOException ioex)
{
- _logger.Warn(fe, "IOException: ");
- _isDeleted = true;
- LineCount = 0;
- FileSize = 0;
- OnFileNotFound(); // notify LogWindow
+ _logger.Warn(ioex);
}
}
-
- private void AddBufferToList(LogBuffer logBuffer)
+ catch (IOException fe)
{
+ _logger.Warn(fe, "IOException: ");
+ _isDeleted = true;
+ LineCount = 0;
+ FileSize = 0;
+ OnFileNotFound(); // notify LogWindow
+ }
+ }
+
+ private void AddBufferToList (LogBuffer logBuffer)
+ {
#if DEBUG
- _logger.Debug("AddBufferToList(): {0}/{1}/{2}", logBuffer.StartLine, logBuffer.LineCount, logBuffer.FileInfo.FullName);
+ _logger.Debug("AddBufferToList(): {0}/{1}/{2}", logBuffer.StartLine, logBuffer.LineCount, logBuffer.FileInfo.FullName);
#endif
- _bufferList.Add(logBuffer);
- //UpdateLru(logBuffer);
- UpdateLruCache(logBuffer);
- }
+ _bufferList.Add(logBuffer);
+ //UpdateLru(logBuffer);
+ UpdateLruCache(logBuffer);
+ }
- private void UpdateLruCache(LogBuffer logBuffer)
+ private void UpdateLruCache (LogBuffer logBuffer)
+ {
+ _lruCacheDictLock.AcquireReaderLock(Timeout.Infinite);
+ if (_lruCacheDict.TryGetValue(logBuffer.StartLine, out LogBufferCacheEntry cacheEntry))
{
- _lruCacheDictLock.AcquireReaderLock(Timeout.Infinite);
- if (_lruCacheDict.TryGetValue(logBuffer.StartLine, out LogBufferCacheEntry cacheEntry))
- {
- cacheEntry.Touch();
- }
- else
+ cacheEntry.Touch();
+ }
+ else
+ {
+ LockCookie cookie = _lruCacheDictLock.UpgradeToWriterLock(Timeout.Infinite);
+ if (!_lruCacheDict.TryGetValue(logBuffer.StartLine, out cacheEntry)
+ ) // #536: re-test, because multiple threads may have been waiting for writer lock
{
- LockCookie cookie = _lruCacheDictLock.UpgradeToWriterLock(Timeout.Infinite);
- if (!_lruCacheDict.TryGetValue(logBuffer.StartLine, out cacheEntry)
- ) // #536: re-test, because multiple threads may have been waiting for writer lock
+ cacheEntry = new LogBufferCacheEntry();
+ cacheEntry.LogBuffer = logBuffer;
+ try
{
- cacheEntry = new LogBufferCacheEntry();
- cacheEntry.LogBuffer = logBuffer;
- try
+ _lruCacheDict.Add(logBuffer.StartLine, cacheEntry);
+ }
+ catch (ArgumentException e)
+ {
+ _logger.Error(e, "Error in LRU cache: " + e.Message);
+#if DEBUG // there seems to be a bug with double added key
+
+ _logger.Info("Added buffer:");
+ DumpBufferInfos(logBuffer);
+ if (_lruCacheDict.TryGetValue(logBuffer.StartLine, out LogBufferCacheEntry existingEntry))
{
- _lruCacheDict.Add(logBuffer.StartLine, cacheEntry);
+ _logger.Info("Existing buffer: ");
+ DumpBufferInfos(existingEntry.LogBuffer);
}
- catch (ArgumentException e)
+ else
{
- _logger.Error(e, "Error in LRU cache: " + e.Message);
-#if DEBUG // there seems to be a bug with double added key
-
- _logger.Info("Added buffer:");
- DumpBufferInfos(logBuffer);
- if (_lruCacheDict.TryGetValue(logBuffer.StartLine, out LogBufferCacheEntry existingEntry))
- {
- _logger.Info("Existing buffer: ");
- DumpBufferInfos(existingEntry.LogBuffer);
- }
- else
- {
- _logger.Warn("Ooops? Cannot find the already existing entry in LRU.");
- }
-#endif
- _lruCacheDictLock.ReleaseLock();
- throw;
+ _logger.Warn("Ooops? Cannot find the already existing entry in LRU.");
}
+#endif
+ _lruCacheDictLock.ReleaseLock();
+ throw;
}
-
- _lruCacheDictLock.DowngradeFromWriterLock(ref cookie);
}
- _lruCacheDictLock.ReleaseReaderLock();
+ _lruCacheDictLock.DowngradeFromWriterLock(ref cookie);
}
- ///
- /// Sets a new start line in the given buffer and updates the LRU cache, if the buffer
- /// is present in the cache. The caller must have write lock for 'lruCacheDictLock';
- ///
- ///
- ///
- private void SetNewStartLineForBuffer(LogBuffer logBuffer, int newLineNum)
+ _lruCacheDictLock.ReleaseReaderLock();
+ }
+
+ ///
+ /// Sets a new start line in the given buffer and updates the LRU cache, if the buffer
+ /// is present in the cache. The caller must have write lock for 'lruCacheDictLock';
+ ///
+ ///
+ ///
+ private void SetNewStartLineForBuffer (LogBuffer logBuffer, int newLineNum)
+ {
+ Util.AssertTrue(_lruCacheDictLock.IsWriterLockHeld, "No writer lock for lru cache");
+ if (_lruCacheDict.ContainsKey(logBuffer.StartLine))
{
- Util.AssertTrue(_lruCacheDictLock.IsWriterLockHeld, "No writer lock for lru cache");
- if (_lruCacheDict.ContainsKey(logBuffer.StartLine))
- {
- _lruCacheDict.Remove(logBuffer.StartLine);
- logBuffer.StartLine = newLineNum;
- LogBufferCacheEntry cacheEntry = new();
- cacheEntry.LogBuffer = logBuffer;
- _lruCacheDict.Add(logBuffer.StartLine, cacheEntry);
- }
- else
- {
- logBuffer.StartLine = newLineNum;
- }
+ _lruCacheDict.Remove(logBuffer.StartLine);
+ logBuffer.StartLine = newLineNum;
+ LogBufferCacheEntry cacheEntry = new();
+ cacheEntry.LogBuffer = logBuffer;
+ _lruCacheDict.Add(logBuffer.StartLine, cacheEntry);
}
-
- private void GarbageCollectLruCache()
+ else
{
+ logBuffer.StartLine = newLineNum;
+ }
+ }
+
+ private void GarbageCollectLruCache ()
+ {
#if DEBUG
- long startTime = Environment.TickCount;
+ long startTime = Environment.TickCount;
#endif
- _logger.Debug("Starting garbage collection");
- int threshold = 10;
- _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite);
- int diff = 0;
- if (_lruCacheDict.Count - (_MAX_BUFFERS + threshold) > 0)
- {
- diff = _lruCacheDict.Count - _MAX_BUFFERS;
+ _logger.Debug("Starting garbage collection");
+ int threshold = 10;
+ _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite);
+ int diff = 0;
+ if (_lruCacheDict.Count - (_MAX_BUFFERS + threshold) > 0)
+ {
+ diff = _lruCacheDict.Count - _MAX_BUFFERS;
#if DEBUG
- if (diff > 0)
- {
- _logger.Info("Removing {0} entries from LRU cache for {1}", diff, Util.GetNameFromPath(_fileName));
- }
+ if (diff > 0)
+ {
+ _logger.Info("Removing {0} entries from LRU cache for {1}", diff, Util.GetNameFromPath(_fileName));
+ }
#endif
- SortedList useSorterList = [];
- // sort by usage counter
- foreach (LogBufferCacheEntry entry in _lruCacheDict.Values)
+ SortedList useSorterList = [];
+ // sort by usage counter
+ foreach (LogBufferCacheEntry entry in _lruCacheDict.Values)
+ {
+ if (!useSorterList.ContainsKey(entry.LastUseTimeStamp))
{
- if (!useSorterList.ContainsKey(entry.LastUseTimeStamp))
- {
- useSorterList.Add(entry.LastUseTimeStamp, entry.LogBuffer.StartLine);
- }
+ useSorterList.Add(entry.LastUseTimeStamp, entry.LogBuffer.StartLine);
}
+ }
- // remove first entries (least usage)
- _disposeLock.AcquireWriterLock(Timeout.Infinite);
- for (int i = 0; i < diff; ++i)
+ // remove first entries (least usage)
+ _disposeLock.AcquireWriterLock(Timeout.Infinite);
+ for (int i = 0; i < diff; ++i)
+ {
+ if (i >= useSorterList.Count)
{
- if (i >= useSorterList.Count)
- {
- break;
- }
-
- int startLine = useSorterList.Values[i];
- LogBufferCacheEntry entry = _lruCacheDict[startLine];
- _lruCacheDict.Remove(startLine);
- entry.LogBuffer.DisposeContent();
+ break;
}
- _disposeLock.ReleaseWriterLock();
+ int startLine = useSorterList.Values[i];
+ LogBufferCacheEntry entry = _lruCacheDict[startLine];
+ _lruCacheDict.Remove(startLine);
+ entry.LogBuffer.DisposeContent();
}
- _lruCacheDictLock.ReleaseWriterLock();
+ _disposeLock.ReleaseWriterLock();
+ }
+
+ _lruCacheDictLock.ReleaseWriterLock();
#if DEBUG
- if (diff > 0)
- {
- long endTime = Environment.TickCount;
- _logger.Info("Garbage collector time: " + (endTime - startTime) + " ms.");
- }
-#endif
+ if (diff > 0)
+ {
+ long endTime = Environment.TickCount;
+ _logger.Info("Garbage collector time: " + (endTime - startTime) + " ms.");
}
+#endif
+ }
- private void GarbageCollectorThreadProc()
+ private void GarbageCollectorThreadProc ()
+ {
+ while (!_shouldStop)
{
- while (!_shouldStop)
+ try
+ {
+ Thread.Sleep(10000);
+ }
+ catch (Exception)
{
- try
- {
- Thread.Sleep(10000);
- }
- catch (Exception)
- {
- }
-
- GarbageCollectLruCache();
}
- }
-
- // private void UpdateLru(LogBuffer logBuffer)
- // {
- // lock (this.monitor)
- // {
- // int index;
- // if (this.lruDict.TryGetValue(logBuffer.StartLine, out index))
- // {
- // RemoveBufferFromLru(logBuffer, index);
- // AddBufferToLru(logBuffer);
- // }
- // else
- // {
- // if (this.bufferLru.Count > MAX_BUFFERS - 1)
- // {
- // LogBuffer looser = this.bufferLru[0];
- // if (looser != null)
- // {
- //#if DEBUG
- // _logger.logDebug("Disposing buffer: " + looser.StartLine + "/" + looser.LineCount + "/" + looser.FileInfo.FileName);
- //#endif
- // looser.DisposeContent();
- // RemoveBufferFromLru(looser);
- // }
- // }
- // AddBufferToLru(logBuffer);
- // }
- // }
- // }
-
- /////
- ///// Removes a LogBuffer from the LRU. Note that the LogBuffer is searched in the lruDict
- ///// via StartLine. So this property must have a consistent value.
- /////
- /////
- //private void RemoveBufferFromLru(LogBuffer buffer)
- //{
- // int index;
- // lock (this.monitor)
- // {
- // if (this.lruDict.TryGetValue(buffer.StartLine, out index))
- // {
- // RemoveBufferFromLru(buffer, index);
- // }
- // }
- //}
- /////
- ///// Removes a LogBuffer from the LRU with known index. Note that the LogBuffer is searched in the lruDict
- ///// via StartLine. So this property must have a consistent value.
- /////
- /////
- /////
- //private void RemoveBufferFromLru(LogBuffer buffer, int index)
- //{
- // lock (this.monitor)
- // {
- // this.bufferLru.RemoveAt(index);
- // this.lruDict.Remove(buffer.StartLine);
- // // adjust indizes, they have changed because of the remove
- // for (int i = index; i < this.bufferLru.Count; ++i)
- // {
- // this.lruDict[this.bufferLru[i].StartLine] = this.lruDict[this.bufferLru[i].StartLine] - 1;
- // }
- // }
- //}
+ GarbageCollectLruCache();
+ }
+ }
- //private void AddBufferToLru(LogBuffer logBuffer)
+ // private void UpdateLru(LogBuffer logBuffer)
+ // {
+ // lock (this.monitor)
+ // {
+ // int index;
+ // if (this.lruDict.TryGetValue(logBuffer.StartLine, out index))
+ // {
+ // RemoveBufferFromLru(logBuffer, index);
+ // AddBufferToLru(logBuffer);
+ // }
+ // else
+ // {
+ // if (this.bufferLru.Count > MAX_BUFFERS - 1)
+ // {
+ // LogBuffer looser = this.bufferLru[0];
+ // if (looser != null)
+ // {
+ //#if DEBUG
+ // _logger.logDebug("Disposing buffer: " + looser.StartLine + "/" + looser.LineCount + "/" + looser.FileInfo.FileName);
+ //#endif
+ // looser.DisposeContent();
+ // RemoveBufferFromLru(looser);
+ // }
+ // }
+ // AddBufferToLru(logBuffer);
+ // }
+ // }
+ // }
+
+ /////
+ ///// Removes a LogBuffer from the LRU. Note that the LogBuffer is searched in the lruDict
+ ///// via StartLine. So this property must have a consistent value.
+ /////
+ /////
+ //private void RemoveBufferFromLru(LogBuffer buffer)
+ //{
+ // int index;
+ // lock (this.monitor)
+ // {
+ // if (this.lruDict.TryGetValue(buffer.StartLine, out index))
+ // {
+ // RemoveBufferFromLru(buffer, index);
+ // }
+ // }
+ //}
+
+ /////
+ ///// Removes a LogBuffer from the LRU with known index. Note that the LogBuffer is searched in the lruDict
+ ///// via StartLine. So this property must have a consistent value.
+ /////
+ /////
+ /////
+ //private void RemoveBufferFromLru(LogBuffer buffer, int index)
+ //{
+ // lock (this.monitor)
+ // {
+ // this.bufferLru.RemoveAt(index);
+ // this.lruDict.Remove(buffer.StartLine);
+ // // adjust indizes, they have changed because of the remove
+ // for (int i = index; i < this.bufferLru.Count; ++i)
+ // {
+ // this.lruDict[this.bufferLru[i].StartLine] = this.lruDict[this.bufferLru[i].StartLine] - 1;
+ // }
+ // }
+ //}
+
+ //private void AddBufferToLru(LogBuffer logBuffer)
+ //{
+ // lock (this.monitor)
+ // {
+ // this.bufferLru.Add(logBuffer);
+ // int newIndex = this.bufferLru.Count - 1;
+ // this.lruDict[logBuffer.StartLine] = newIndex;
+ // }
+ //}
+
+ private void ClearLru ()
+ {
+ //lock (this.monitor)
//{
- // lock (this.monitor)
+ // foreach (LogBuffer buffer in this.bufferLru)
// {
- // this.bufferLru.Add(logBuffer);
- // int newIndex = this.bufferLru.Count - 1;
- // this.lruDict[logBuffer.StartLine] = newIndex;
+ // buffer.DisposeContent();
// }
+ // this.bufferLru.Clear();
+ // this.lruDict.Clear();
//}
-
- private void ClearLru()
- {
- //lock (this.monitor)
- //{
- // foreach (LogBuffer buffer in this.bufferLru)
- // {
- // buffer.DisposeContent();
- // }
- // this.bufferLru.Clear();
- // this.lruDict.Clear();
- //}
- _logger.Info("Clearing LRU cache.");
- _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite);
- _disposeLock.AcquireWriterLock(Timeout.Infinite);
- foreach (LogBufferCacheEntry entry in _lruCacheDict.Values)
- {
- entry.LogBuffer.DisposeContent();
- }
-
- _lruCacheDict.Clear();
- _disposeLock.ReleaseWriterLock();
- _lruCacheDictLock.ReleaseWriterLock();
- _logger.Info("Clearing done.");
+ _logger.Info("Clearing LRU cache.");
+ _lruCacheDictLock.AcquireWriterLock(Timeout.Infinite);
+ _disposeLock.AcquireWriterLock(Timeout.Infinite);
+ foreach (LogBufferCacheEntry entry in _lruCacheDict.Values)
+ {
+ entry.LogBuffer.DisposeContent();
}
- private void ReReadBuffer(LogBuffer logBuffer)
- {
+ _lruCacheDict.Clear();
+ _disposeLock.ReleaseWriterLock();
+ _lruCacheDictLock.ReleaseWriterLock();
+ _logger.Info("Clearing done.");
+ }
+
+ private void ReReadBuffer (LogBuffer logBuffer)
+ {
#if DEBUG
- _logger.Info("re-reading buffer: {0}/{1}/{2}", logBuffer.StartLine, logBuffer.LineCount, logBuffer.FileInfo.FullName);
+ _logger.Info("re-reading buffer: {0}/{1}/{2}", logBuffer.StartLine, logBuffer.LineCount, logBuffer.FileInfo.FullName);
#endif
+ try
+ {
+ Monitor.Enter(logBuffer);
+ Stream fileStream = null;
try
{
- Monitor.Enter(logBuffer);
- Stream fileStream = null;
- try
- {
- fileStream = logBuffer.FileInfo.OpenStream();
- }
- catch (IOException e)
- {
- _logger.Warn(e);
- return;
- }
+ fileStream = logBuffer.FileInfo.OpenStream();
+ }
+ catch (IOException e)
+ {
+ _logger.Warn(e);
+ return;
+ }
- try
- {
- ILogStreamReader reader = GetLogStreamReader(fileStream, EncodingOptions, UseNewReader);
+ try
+ {
+ ILogStreamReader reader = GetLogStreamReader(fileStream, EncodingOptions, UseNewReader);
- long filePos = logBuffer.StartPos;
- reader.Position = logBuffer.StartPos;
- int maxLinesCount = logBuffer.LineCount;
- int lineCount = 0;
- int dropCount = logBuffer.PrevBuffersDroppedLinesSum;
- logBuffer.ClearLines();
+ long filePos = logBuffer.StartPos;
+ reader.Position = logBuffer.StartPos;
+ int maxLinesCount = logBuffer.LineCount;
+ int lineCount = 0;
+ int dropCount = logBuffer.PrevBuffersDroppedLinesSum;
+ logBuffer.ClearLines();
- while (ReadLine(reader, logBuffer.StartLine + logBuffer.LineCount, logBuffer.StartLine + logBuffer.LineCount + dropCount, out string line))
+ while (ReadLine(reader, logBuffer.StartLine + logBuffer.LineCount, logBuffer.StartLine + logBuffer.LineCount + dropCount, out string line))
+ {
+ if (lineCount >= maxLinesCount)
{
- if (lineCount >= maxLinesCount)
- {
- break;
- }
-
- if (line == null)
- {
- dropCount++;
- continue;
- }
-
- LogLine logLine = new()
- {
- FullLine = line,
- LineNumber = logBuffer.StartLine + logBuffer.LineCount
- };
-
- logBuffer.AddLine(logLine, filePos);
- filePos = reader.Position;
- lineCount++;
+ break;
}
- if (maxLinesCount != logBuffer.LineCount)
+ if (line == null)
{
- _logger.Warn("LineCount in buffer differs after re-reading. old={0}, new={1}", maxLinesCount, logBuffer.LineCount);
+ dropCount++;
+ continue;
}
- if (dropCount - logBuffer.PrevBuffersDroppedLinesSum != logBuffer.DroppedLinesCount)
+ LogLine logLine = new()
{
- _logger.Warn("DroppedLinesCount in buffer differs after re-reading. old={0}, new={1}", logBuffer.DroppedLinesCount, dropCount);
- logBuffer.DroppedLinesCount = dropCount - logBuffer.PrevBuffersDroppedLinesSum;
- }
+ FullLine = line,
+ LineNumber = logBuffer.StartLine + logBuffer.LineCount
+ };
- GC.KeepAlive(fileStream);
+ logBuffer.AddLine(logLine, filePos);
+ filePos = reader.Position;
+ lineCount++;
}
- catch (IOException e)
+
+ if (maxLinesCount != logBuffer.LineCount)
{
- _logger.Warn(e);
+ _logger.Warn("LineCount in buffer differs after re-reading. old={0}, new={1}", maxLinesCount, logBuffer.LineCount);
}
- finally
+
+ if (dropCount - logBuffer.PrevBuffersDroppedLinesSum != logBuffer.DroppedLinesCount)
{
- fileStream.Close();
+ _logger.Warn("DroppedLinesCount in buffer differs after re-reading. old={0}, new={1}", logBuffer.DroppedLinesCount, dropCount);
+ logBuffer.DroppedLinesCount = dropCount - logBuffer.PrevBuffersDroppedLinesSum;
}
+
+ GC.KeepAlive(fileStream);
+ }
+ catch (IOException e)
+ {
+ _logger.Warn(e);
}
finally
{
- Monitor.Exit(logBuffer);
+ fileStream.Close();
}
}
-
- private LogBuffer GetBufferForLine(int lineNum)
+ finally
{
+ Monitor.Exit(logBuffer);
+ }
+ }
+
+ private LogBuffer GetBufferForLine (int lineNum)
+ {
#if DEBUG
- long startTime = Environment.TickCount;
+ long startTime = Environment.TickCount;
#endif
- LogBuffer logBuffer = null;
- AcquireBufferListReaderLock();
- //if (lineNum == this.lastReturnedLineNumForBuffer)
- //{
- // return this.lastReturnedBuffer;
- //}
-
- //int startIndex = lineNum / LogBuffer.MAX_LINES; // doesn't work anymore since XML buffer may contain more lines than MAX_LINES
- int startIndex = 0;
- int count = _bufferList.Count;
- for (int i = startIndex; i < count; ++i)
+ LogBuffer logBuffer = null;
+ AcquireBufferListReaderLock();
+ //if (lineNum == this.lastReturnedLineNumForBuffer)
+ //{
+ // return this.lastReturnedBuffer;
+ //}
+
+ //int startIndex = lineNum / LogBuffer.MAX_LINES; // doesn't work anymore since XML buffer may contain more lines than MAX_LINES
+ int startIndex = 0;
+ int count = _bufferList.Count;
+ for (int i = startIndex; i < count; ++i)
+ {
+ logBuffer = _bufferList[i];
+ if (lineNum >= logBuffer.StartLine && lineNum < logBuffer.StartLine + logBuffer.LineCount)
{
- logBuffer = _bufferList[i];
- if (lineNum >= logBuffer.StartLine && lineNum < logBuffer.StartLine + logBuffer.LineCount)
- {
- //UpdateLru(logBuffer);
- UpdateLruCache(logBuffer);
- //this.lastReturnedLineNumForBuffer = lineNum;
- //this.lastReturnedBuffer = logBuffer;
- break;
- }
+ //UpdateLru(logBuffer);
+ UpdateLruCache(logBuffer);
+ //this.lastReturnedLineNumForBuffer = lineNum;
+ //this.lastReturnedBuffer = logBuffer;
+ break;
}
+ }
#if DEBUG
- long endTime = Environment.TickCount;
- //_logger.logDebug("getBufferForLine(" + lineNum + ") duration: " + ((endTime - startTime)) + " ms. Buffer start line: " + logBuffer.StartLine);
+ long endTime = Environment.TickCount;
+ //_logger.logDebug("getBufferForLine(" + lineNum + ") duration: " + ((endTime - startTime)) + " ms. Buffer start line: " + logBuffer.StartLine);
#endif
+ ReleaseBufferListReaderLock();
+ return logBuffer;
+ }
+
+ ///
+ /// Async callback used to check if the GetLogLine() call is succeeding again after a detected timeout.
+ ///
+ private void GetLineFinishedCallback (ILogLine line)
+ {
+ _isFailModeCheckCallPending = false;
+ if (line != null)
+ {
+ _logger.Debug("'isFastFailOnGetLogLine' flag was reset");
+ _isFastFailOnGetLogLine = false;
+ }
+
+ _logger.Debug("'isLogLineCallPending' flag was reset.");
+ }
+
+ private LogBuffer GetFirstBufferForFileByLogBuffer (LogBuffer logBuffer)
+ {
+ ILogFileInfo info = logBuffer.FileInfo;
+ AcquireBufferListReaderLock();
+ int index = _bufferList.IndexOf(logBuffer);
+ if (index == -1)
+ {
ReleaseBufferListReaderLock();
- return logBuffer;
+ return null;
}
- ///
- /// Async callback used to check if the GetLogLine() call is succeeding again after a detected timeout.
- ///
- private void GetLineFinishedCallback(ILogLine line)
+ LogBuffer resultBuffer = logBuffer;
+ while (true)
{
- _isFailModeCheckCallPending = false;
- if (line != null)
+ index--;
+ if (index < 0 || _bufferList[index].FileInfo != info)
{
- _logger.Debug("'isFastFailOnGetLogLine' flag was reset");
- _isFastFailOnGetLogLine = false;
+ break;
}
- _logger.Debug("'isLogLineCallPending' flag was reset.");
+ resultBuffer = _bufferList[index];
}
- private LogBuffer GetFirstBufferForFileByLogBuffer(LogBuffer logBuffer)
- {
- ILogFileInfo info = logBuffer.FileInfo;
- AcquireBufferListReaderLock();
- int index = _bufferList.IndexOf(logBuffer);
- if (index == -1)
- {
- ReleaseBufferListReaderLock();
- return null;
- }
+ ReleaseBufferListReaderLock();
+ return resultBuffer;
+ }
- LogBuffer resultBuffer = logBuffer;
- while (true)
- {
- index--;
- if (index < 0 || _bufferList[index].FileInfo != info)
- {
- break;
- }
+ private void MonitorThreadProc ()
+ {
+ Thread.CurrentThread.Name = "MonitorThread";
+ //IFileSystemPlugin fs = PluginRegistry.GetInstance().FindFileSystemForUri(this.watchedILogFileInfo.FullName);
+ _logger.Info("MonitorThreadProc() for file {0}", _watchedILogFileInfo.FullName);
- resultBuffer = _bufferList[index];
+ long oldSize = 0;
+ try
+ {
+ OnLoadingStarted(new LoadFileEventArgs(_fileName, 0, false, 0, false));
+ ReadFiles();
+ if (!_isDeleted)
+ {
+ oldSize = _fileLength;
+ OnLoadingFinished();
}
-
- ReleaseBufferListReaderLock();
- return resultBuffer;
}
-
- private void MonitorThreadProc()
+ catch (Exception e)
{
- Thread.CurrentThread.Name = "MonitorThread";
- //IFileSystemPlugin fs = PluginRegistry.GetInstance().FindFileSystemForUri(this.watchedILogFileInfo.FullName);
- _logger.Info("MonitorThreadProc() for file {0}", _watchedILogFileInfo.FullName);
+ _logger.Error(e);
+ }
- long oldSize = 0;
+ while (!_shouldStop)
+ {
try
{
- OnLoadingStarted(new LoadFileEventArgs(_fileName, 0, false, 0, false));
- ReadFiles();
- if (!_isDeleted)
- {
- oldSize = _fileLength;
- OnLoadingFinished();
- }
+ int pollInterval = _watchedILogFileInfo.PollInterval;
+ //#if DEBUG
+ // if (_logger.IsDebug)
+ // {
+ // _logger.logDebug("Poll interval for " + this.fileName + ": " + pollInterval);
+ // }
+ //#endif
+ Thread.Sleep(pollInterval);
}
catch (Exception e)
{
_logger.Error(e);
}
- while (!_shouldStop)
+ if (_shouldStop)
{
- try
- {
- int pollInterval = _watchedILogFileInfo.PollInterval;
- //#if DEBUG
- // if (_logger.IsDebug)
- // {
- // _logger.logDebug("Poll interval for " + this.fileName + ": " + pollInterval);
- // }
- //#endif
- Thread.Sleep(pollInterval);
- }
- catch (Exception e)
- {
- _logger.Error(e);
- }
-
- if (_shouldStop)
- {
- return;
- }
+ return;
+ }
- try
+ try
+ {
+ if (_watchedILogFileInfo.FileHasChanged())
{
- if (_watchedILogFileInfo.FileHasChanged())
+ _fileLength = _watchedILogFileInfo.Length;
+ if (_fileLength == -1)
{
- _fileLength = _watchedILogFileInfo.Length;
- if (_fileLength == -1)
- {
- MonitoredFileNotFound();
- }
- else
- {
- oldSize = _fileLength;
- FileChanged();
- }
+ MonitoredFileNotFound();
+ }
+ else
+ {
+ oldSize = _fileLength;
+ FileChanged();
}
}
- catch (FileNotFoundException)
- {
- MonitoredFileNotFound();
- }
+ }
+ catch (FileNotFoundException)
+ {
+ MonitoredFileNotFound();
}
}
+ }
- private void MonitoredFileNotFound()
+ private void MonitoredFileNotFound ()
+ {
+ long oldSize;
+ if (!_isDeleted)
{
- long oldSize;
- if (!_isDeleted)
- {
- _logger.Debug("File not FileNotFoundException catched. Switching to 'deleted' mode.");
- _isDeleted = true;
- oldSize = _fileLength = -1;
- FileSize = 0;
- OnFileNotFound(); // notify LogWindow
- }
+ _logger.Debug("File not FileNotFoundException catched. Switching to 'deleted' mode.");
+ _isDeleted = true;
+ oldSize = _fileLength = -1;
+ FileSize = 0;
+ OnFileNotFound(); // notify LogWindow
+ }
#if DEBUG
- else
- {
- _logger.Debug("File not FileNotFoundException catched. Already in deleted mode.");
- }
-#endif
+ else
+ {
+ _logger.Debug("File not FileNotFoundException catched. Already in deleted mode.");
}
+#endif
+ }
- private void FileChanged()
+ private void FileChanged ()
+ {
+ if (_isDeleted)
{
- if (_isDeleted)
- {
- OnRespawned();
- // prevent size update events. The window should reload the complete file.
- FileSize = _fileLength;
- }
-
- long newSize = _fileLength;
- //if (this.currFileSize != newSize)
- {
- _logger.Info("file size changed. new size={0}, file: {1}", newSize, _fileName);
- FireChangeEvent();
- }
+ OnRespawned();
+ // prevent size update events. The window should reload the complete file.
+ FileSize = _fileLength;
}
- private void FireChangeEvent()
+ long newSize = _fileLength;
+ //if (this.currFileSize != newSize)
{
- LogEventArgs args = new();
- args.PrevFileSize = FileSize;
- args.PrevLineCount = LineCount;
- long newSize = _fileLength;
- if (newSize < FileSize || _isDeleted)
+ _logger.Info("file size changed. new size={0}, file: {1}", newSize, _fileName);
+ FireChangeEvent();
+ }
+ }
+
+ private void FireChangeEvent ()
+ {
+ LogEventArgs args = new();
+ args.PrevFileSize = FileSize;
+ args.PrevLineCount = LineCount;
+ long newSize = _fileLength;
+ if (newSize < FileSize || _isDeleted)
+ {
+ _logger.Info("File was created anew: new size={0}, oldSize={1}", newSize, FileSize);
+ // Fire "New File" event
+ FileSize = 0;
+ LineCount = 0;
+ try
{
- _logger.Info("File was created anew: new size={0}, oldSize={1}", newSize, FileSize);
- // Fire "New File" event
- FileSize = 0;
- LineCount = 0;
- try
+ if (!IsMultiFile)
{
- if (!IsMultiFile)
- {
- // ReloadBufferList(); // removed because reloading is triggered by owning LogWindow
- // Trigger "new file" handling (reload)
- OnLoadFile(new LoadFileEventArgs(_fileName, 0, true, _fileLength, true));
+ // 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
+ if (_isDeleted)
{
- int offset = ShiftBuffers();
- //this.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)
+ if (args.PrevLineCount != args.LineCount && !_shouldStop)
{
OnFileSizeChanged(args);
}
}
+
+ _isDeleted = false;
}
- catch (FileNotFoundException e)
+ else
{
- // trying anew in next poll intervall. So let currFileSize untouched.
- _logger.Warn(e);
+ int offset = ShiftBuffers();
+ //this.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);
+ }
}
}
- else
+ catch (FileNotFoundException e)
{
- ReadToBufferList(_watchedILogFileInfo, FileSize, LineCount);
- args.FileSize = newSize;
- args.LineCount = LineCount;
- //if (args.PrevLineCount != args.LineCount && !this.shouldStop)
- OnFileSizeChanged(args);
+ // trying anew in next poll intervall. So let currFileSize untouched.
+ _logger.Warn(e);
}
}
-
- private ILogStreamReader GetLogStreamReader(Stream stream, EncodingOptions encodingOptions, bool useNewReader)
+ else
{
- ILogStreamReader reader = CreateLogStreamReader(stream, encodingOptions, useNewReader);
-
- return IsXmlMode ? new XmlBlockSplitter(new XmlLogReader(reader), XmlLogConfig) : reader;
+ ReadToBufferList(_watchedILogFileInfo, FileSize, LineCount);
+ args.FileSize = newSize;
+ args.LineCount = LineCount;
+ //if (args.PrevLineCount != args.LineCount && !this.shouldStop)
+ OnFileSizeChanged(args);
}
+ }
- private ILogStreamReader CreateLogStreamReader(Stream stream, EncodingOptions encodingOptions, bool useSystemReader)
- {
- if (useSystemReader)
- {
- return new PositionAwareStreamReaderSystem(stream, encodingOptions);
- }
+ private ILogStreamReader GetLogStreamReader (Stream stream, EncodingOptions encodingOptions, bool useNewReader)
+ {
+ ILogStreamReader reader = CreateLogStreamReader(stream, encodingOptions, useNewReader);
- return new PositionAwareStreamReaderLegacy(stream, encodingOptions);
- }
+ return IsXmlMode ? new XmlBlockSplitter(new XmlLogReader(reader), XmlLogConfig) : reader;
+ }
- private bool ReadLine(ILogStreamReader reader, int lineNum, int realLineNum, out string outLine)
+ private ILogStreamReader CreateLogStreamReader (Stream stream, EncodingOptions encodingOptions, bool useSystemReader)
+ {
+ if (useSystemReader)
{
- string line = null;
- try
- {
- line = reader.ReadLine();
- }
- catch (IOException e)
- {
- _logger.Warn(e);
- }
- catch (NotSupportedException e)
- {
- // Bug#11: "Reading operations are not supported by the stream"
- // Currently not reproducible. Probably happens at an unlucky time interval (after opening the file)
- // when the file is being deleted (rolling)
- // This will be handled as EOF.
- _logger.Warn(e);
- }
+ return new PositionAwareStreamReaderSystem(stream, encodingOptions);
+ }
- if (line == null) // EOF or catched Exception
- {
- outLine = null;
- return false;
- }
+ return new PositionAwareStreamReaderLegacy(stream, encodingOptions);
+ }
- if (PreProcessColumnizer != null)
- {
- line = PreProcessColumnizer.PreProcessLine(line, lineNum, realLineNum);
- }
+ private bool ReadLine (ILogStreamReader reader, int lineNum, int realLineNum, out string outLine)
+ {
+ string line = null;
+ try
+ {
+ line = reader.ReadLine();
+ }
+ catch (IOException e)
+ {
+ _logger.Warn(e);
+ }
+ catch (NotSupportedException e)
+ {
+ // Bug#11: "Reading operations are not supported by the stream"
+ // Currently not reproducible. Probably happens at an unlucky time interval (after opening the file)
+ // when the file is being deleted (rolling)
+ // This will be handled as EOF.
+ _logger.Warn(e);
+ }
- outLine = line;
- return true;
+ if (line == null) // EOF or catched Exception
+ {
+ outLine = null;
+ return false;
}
- private void AcquireBufferListReaderLock()
+ if (PreProcessColumnizer != null)
{
- try
- {
- _bufferListLock.AcquireReaderLock(10000);
+ line = PreProcessColumnizer.PreProcessLine(line, lineNum, realLineNum);
+ }
+
+ outLine = line;
+ return true;
+ }
+
+ private void AcquireBufferListReaderLock ()
+ {
+ try
+ {
+ _bufferListLock.AcquireReaderLock(10000);
#if DEBUG && TRACE_LOCKS
- StackTrace st = new StackTrace(true);
- StackFrame callerFrame = st.GetFrame(2);
- this.bufferListLockInfo =
+ StackTrace st = new StackTrace(true);
+ StackFrame callerFrame = st.GetFrame(2);
+ this.bufferListLockInfo =
"Read lock from " + callerFrame.GetMethod().DeclaringType.Name + "." + callerFrame.GetMethod().Name + "() " + callerFrame.GetFileLineNumber();
#endif
- }
- catch (ApplicationException e)
- {
- _logger.Warn(e, "Reader lock wait for bufferList timed out. Now trying infinite.");
+ }
+ catch (ApplicationException e)
+ {
+ _logger.Warn(e, "Reader lock wait for bufferList timed out. Now trying infinite.");
#if DEBUG && TRACE_LOCKS
- _logger.logInfo(this.bufferListLockInfo);
+ _logger.logInfo(this.bufferListLockInfo);
#endif
- _bufferListLock.AcquireReaderLock(Timeout.Infinite);
- }
+ _bufferListLock.AcquireReaderLock(Timeout.Infinite);
}
+ }
- private void ReleaseBufferListReaderLock()
- {
- _bufferListLock.ReleaseReaderLock();
- }
+ private void ReleaseBufferListReaderLock ()
+ {
+ _bufferListLock.ReleaseReaderLock();
+ }
- private void AcquireBufferListWriterLock()
+ private void AcquireBufferListWriterLock ()
+ {
+ try
{
- try
- {
- _bufferListLock.AcquireWriterLock(10000);
+ _bufferListLock.AcquireWriterLock(10000);
#if DEBUG && TRACE_LOCKS
- StackTrace st = new StackTrace(true);
- StackFrame callerFrame = st.GetFrame(1);
- this.bufferListLockInfo =
+ StackTrace st = new StackTrace(true);
+ StackFrame callerFrame = st.GetFrame(1);
+ this.bufferListLockInfo =
"Write lock from " + callerFrame.GetMethod().DeclaringType.Name + "." + callerFrame.GetMethod().Name + "() " + callerFrame.GetFileLineNumber();
- callerFrame.GetFileName();
+ callerFrame.GetFileName();
#endif
- }
- catch (ApplicationException e)
- {
- _logger.Warn(e, "Writer lock wait for bufferList timed out. Now trying infinite.");
+ }
+ catch (ApplicationException e)
+ {
+ _logger.Warn(e, "Writer lock wait for bufferList timed out. Now trying infinite.");
#if DEBUG && TRACE_LOCKS
- _logger.logInfo(this.bufferListLockInfo);
+ _logger.logInfo(this.bufferListLockInfo);
#endif
- _bufferListLock.AcquireWriterLock(Timeout.Infinite);
- }
+ _bufferListLock.AcquireWriterLock(Timeout.Infinite);
}
+ }
- private void ReleaseBufferListWriterLock()
- {
- _bufferListLock.ReleaseWriterLock();
- }
+ private void ReleaseBufferListWriterLock ()
+ {
+ _bufferListLock.ReleaseWriterLock();
+ }
- private LockCookie UpgradeBufferListLockToWriter()
+ private LockCookie UpgradeBufferListLockToWriter ()
+ {
+ try
{
- try
- {
- LockCookie cookie = _bufferListLock.UpgradeToWriterLock(10000);
+ LockCookie cookie = _bufferListLock.UpgradeToWriterLock(10000);
#if DEBUG && TRACE_LOCKS
- StackTrace st = new StackTrace(true);
- StackFrame callerFrame = st.GetFrame(2);
- this.bufferListLockInfo +=
+ StackTrace st = new StackTrace(true);
+ StackFrame callerFrame = st.GetFrame(2);
+ this.bufferListLockInfo +=
", upgraded to writer from " + callerFrame.GetMethod().DeclaringType.Name + "." + callerFrame.GetMethod().Name + "() " + callerFrame.GetFileLineNumber();
#endif
- return cookie;
- }
- catch (ApplicationException e)
- {
- _logger.Warn(e, "Writer lock update wait for bufferList timed out. Now trying infinite.");
+ return cookie;
+ }
+ catch (ApplicationException e)
+ {
+ _logger.Warn(e, "Writer lock update wait for bufferList timed out. Now trying infinite.");
#if DEBUG && TRACE_LOCKS
- _logger.logInfo(this.bufferListLockInfo);
+ _logger.logInfo(this.bufferListLockInfo);
#endif
- return _bufferListLock.UpgradeToWriterLock(Timeout.Infinite);
- }
+ return _bufferListLock.UpgradeToWriterLock(Timeout.Infinite);
}
+ }
- private void DowngradeBufferListLockFromWriter(ref LockCookie cookie)
- {
- _bufferListLock.DowngradeFromWriterLock(ref cookie);
+ private void DowngradeBufferListLockFromWriter (ref LockCookie cookie)
+ {
+ _bufferListLock.DowngradeFromWriterLock(ref cookie);
#if DEBUG && TRACE_LOCKS
- StackTrace st = new StackTrace(true);
- StackFrame callerFrame = st.GetFrame(2);
- this.bufferListLockInfo +=
+ StackTrace st = new StackTrace(true);
+ StackFrame callerFrame = st.GetFrame(2);
+ this.bufferListLockInfo +=
", downgraded to reader from " + callerFrame.GetMethod().DeclaringType.Name + "." + callerFrame.GetMethod().Name + "() " + callerFrame.GetFileLineNumber();
#endif
- }
+ }
#if DEBUG
- private void DumpBufferInfos(LogBuffer buffer)
+ private void DumpBufferInfos (LogBuffer buffer)
+ {
+ if (_logger.IsTraceEnabled)
{
- if (_logger.IsTraceEnabled)
- {
- _logger.Trace("StartLine: {0}\r\nLineCount: {1}\r\nStartPos: {2}\r\nSize: {3}\r\nDisposed: {4}\r\nDisposeCount: {5}\r\nFile: {6}",
- buffer.StartLine,
- buffer.LineCount,
- buffer.StartPos,
- buffer.Size,
- buffer.IsDisposed ? "yes" : "no",
- buffer.DisposeCount,
- buffer.FileInfo.FullName);
- }
+ _logger.Trace("StartLine: {0}\r\nLineCount: {1}\r\nStartPos: {2}\r\nSize: {3}\r\nDisposed: {4}\r\nDisposeCount: {5}\r\nFile: {6}",
+ buffer.StartLine,
+ buffer.LineCount,
+ buffer.StartPos,
+ buffer.Size,
+ buffer.IsDisposed ? "yes" : "no",
+ buffer.DisposeCount,
+ buffer.FileInfo.FullName);
}
+ }
#endif
- #endregion
+ #endregion
- ~LogfileReader()
- {
- DeleteAllContent();
- }
+ ~LogfileReader ()
+ {
+ DeleteAllContent();
+ }
- protected virtual void OnFileSizeChanged(LogEventArgs e)
- {
- FileSizeChanged?.Invoke(this, e);
- }
+ protected virtual void OnFileSizeChanged (LogEventArgs e)
+ {
+ FileSizeChanged?.Invoke(this, e);
+ }
- protected virtual void OnLoadFile(LoadFileEventArgs e)
- {
- LoadFile?.Invoke(this, e);
- }
+ protected virtual void OnLoadFile (LoadFileEventArgs e)
+ {
+ LoadFile?.Invoke(this, e);
+ }
- protected virtual void OnLoadingStarted(LoadFileEventArgs e)
- {
- LoadingStarted?.Invoke(this, e);
- }
+ protected virtual void OnLoadingStarted (LoadFileEventArgs e)
+ {
+ LoadingStarted?.Invoke(this, e);
+ }
- protected virtual void OnLoadingFinished()
- {
- LoadingFinished?.Invoke(this, EventArgs.Empty);
- }
+ protected virtual void OnLoadingFinished ()
+ {
+ LoadingFinished?.Invoke(this, EventArgs.Empty);
+ }
- protected virtual void OnFileNotFound()
- {
- FileNotFound?.Invoke(this, EventArgs.Empty);
- }
+ protected virtual void OnFileNotFound ()
+ {
+ FileNotFound?.Invoke(this, EventArgs.Empty);
+ }
- protected virtual void OnRespawned()
- {
- _logger.Info("OnRespawned()");
- Respawned?.Invoke(this, EventArgs.Empty);
- }
+ protected virtual void OnRespawned ()
+ {
+ _logger.Info("OnRespawned()");
+ Respawned?.Invoke(this, EventArgs.Empty);
+ }
- private class LogLine : ILogLine
- {
- #region Properties
+ private class LogLine : ILogLine
+ {
+ #region Properties
- public string FullLine { get; set; }
+ public string FullLine { get; set; }
- public int LineNumber { get; set; }
+ public int LineNumber { get; set; }
- string ITextValue.Text => FullLine;
+ string ITextValue.Text => FullLine;
- #endregion
- }
+ #endregion
}
}
\ No newline at end of file
diff --git a/src/LogExpert.Core/Classes/Util.cs b/src/LogExpert.Core/Classes/Util.cs
index f4ab307a..b8b7c904 100644
--- a/src/LogExpert.Core/Classes/Util.cs
+++ b/src/LogExpert.Core/Classes/Util.cs
@@ -1,570 +1,629 @@
-using LogExpert.Core.Classes.Filter;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
-namespace LogExpert.Core.Classes
+using LogExpert.Core.Classes.Filter;
+
+namespace LogExpert.Core.Classes;
+
+public class Util
{
- public class Util
+ #region Public methods
+
+ public static string GetNameFromPath (string fileName)
{
- #region Public methods
+ var i = fileName.LastIndexOf('\\');
- public static string GetNameFromPath(string fileName)
+ if (i < 0)
{
- int i = fileName.LastIndexOf('\\');
- if (i < 0)
- {
- i = fileName.LastIndexOf('/');
- }
- if (i < 0)
- {
- i = -1;
- }
- return fileName[(i + 1)..];
+ i = fileName.LastIndexOf('/');
}
- public static string StripExtension(string fileName)
+ if (i < 0)
{
- int i = fileName.LastIndexOf('.');
- if (i < 0)
- {
- i = fileName.Length - 1;
- }
- return fileName[..i];
+ i = -1;
}
- public static string GetExtension(string fileName)
+ return fileName[(i + 1)..];
+ }
+
+ //TODO Add Null Check (https://github.com/LogExperts/LogExpert/issues/403)
+ public static string StripExtension (string fileName)
+ {
+ var i = fileName.LastIndexOf('.');
+
+ if (i < 0)
{
- int i = fileName.LastIndexOf('.');
- if (i < 0 || i >= fileName.Length - 1)
- {
- return "";
- }
- else
- {
- return fileName[(i + 1)..];
- }
+ i = fileName.Length - 1;
}
+ return fileName[..i];
+ }
+
+ //TODO Add Null Check (https://github.com/LogExperts/LogExpert/issues/403)
+ public static string GetExtension (string fileName)
+ {
+ var i = fileName.LastIndexOf('.');
+
+ return i < 0 || i >= fileName.Length - 1
+ ? string.Empty
+ : fileName[(i + 1)..];
+ }
+
+
+ public static string GetFileSizeAsText (long size)
+ {
+ return size < 1024
+ ? string.Empty + size + " bytes"
+ : size < 1024 * 1024
+ ? string.Empty + (size / 1024) + " KB"
+ : string.Empty + $"{size / 1048576.0:0.00}" + " MB";
+ }
- public static string GetFileSizeAsText(long size)
+ public static bool TestFilterCondition (FilterParams filterParams, ILogLine line, ILogLineColumnizerCallback columnizerCallback)
+ {
+ if (filterParams.LastLine.Equals(line.FullLine))
{
- if (size < 1024)
- {
- return "" + size + " bytes";
- }
- else if (size < 1024 * 1024)
- {
- return "" + size / 1024 + " KB";
- }
- else
- {
- return "" + string.Format("{0:0.00}", size / 1048576.0) + " MB";
- }
+ return filterParams.LastResult;
}
- public static bool TestFilterCondition(FilterParams filterParams, ILogLine line,
- LogExpert.ILogLineColumnizerCallback columnizerCallback)
+ var match = TestFilterMatch(filterParams, line, columnizerCallback);
+ filterParams.LastLine = line.FullLine;
+
+ if (filterParams.IsRangeSearch)
{
- if (filterParams.LastLine.Equals(line.FullLine))
+ if (!filterParams.IsInRange)
{
- return filterParams.LastResult;
+ if (match)
+ {
+ filterParams.IsInRange = true;
+ }
}
-
- bool match = TestFilterMatch(filterParams, line, columnizerCallback);
- filterParams.LastLine = line.FullLine;
-
- if (filterParams.IsRangeSearch)
+ else
{
- if (!filterParams.IsInRange)
+ if (!match)
{
- if (match)
- {
- filterParams.IsInRange = true;
- }
+ match = true;
}
else
{
- if (!match)
- {
- match = true;
- }
- else
- {
- filterParams.IsInRange = false;
- }
+ filterParams.IsInRange = false;
}
}
- if (filterParams.IsInvert)
- {
- match = !match;
- }
- filterParams.LastResult = match;
- return match;
}
+ if (filterParams.IsInvert)
+ {
+ match = !match;
+ }
+
+ filterParams.LastResult = match;
+ return match;
+ }
- public static int DamerauLevenshteinDistance(string src, string dest)
+ //TODO Add Null Checks (https://github.com/LogExperts/LogExpert/issues/403)
+ public static int DamerauLevenshteinDistance (string src, string dest)
+ {
+ var d = new int[src.Length + 1, dest.Length + 1];
+ int i, j, cost;
+ var str1 = src.ToCharArray();
+ var str2 = dest.ToCharArray();
+
+ for (i = 0; i <= str1.Length; i++)
{
- int[,] d = new int[src.Length + 1, dest.Length + 1];
- int i, j, cost;
- char[] str1 = src.ToCharArray();
- char[] str2 = dest.ToCharArray();
+ d[i, 0] = i;
+ }
- for (i = 0; i <= str1.Length; i++)
- {
- d[i, 0] = i;
- }
- for (j = 0; j <= str2.Length; j++)
- {
- d[0, j] = j;
- }
- for (i = 1; i <= str1.Length; i++)
+ for (j = 0; j <= str2.Length; j++)
+ {
+ d[0, j] = j;
+ }
+
+ for (i = 1; i <= str1.Length; i++)
+ {
+ for (j = 1; j <= str2.Length; j++)
{
- for (j = 1; j <= str2.Length; j++)
- {
- if (str1[i - 1] == str2[j - 1])
- {
- cost = 0;
- }
- else
- {
- cost = 1;
- }
+ cost = str1[i - 1] == str2[j - 1]
+ ? 0
+ : 1;
- d[i, j] =
- Math.Min(d[i - 1, j] + 1, // Deletion
- Math.Min(d[i, j - 1] + 1, // Insertion
- d[i - 1, j - 1] + cost)); // Substitution
+ d[i, j] =
+ Math.Min(d[i - 1, j] + 1, // Deletion
+ Math.Min(d[i, j - 1] + 1, // Insertion
+ d[i - 1, j - 1] + cost)); // Substitution
- if (i > 1 && j > 1 && str1[i - 1] == str2[j - 2] && str1[i - 2] == str2[j - 1])
- {
- d[i, j] = Math.Min(d[i, j], d[i - 2, j - 2] + cost);
- }
+ if (i > 1 && j > 1 && str1[i - 1] == str2[j - 2] && str1[i - 2] == str2[j - 1])
+ {
+ d[i, j] = Math.Min(d[i, j], d[i - 2, j - 2] + cost);
}
}
- return d[str1.Length, str2.Length];
}
+ return d[str1.Length, str2.Length];
+ }
+
+ //TODO Add Null Checks (https://github.com/LogExperts/LogExpert/issues/403)
+ public static unsafe int YetiLevenshtein (string s1, string s2)
+ {
+ fixed (char* p1 = s1)
+ fixed (char* p2 = s2)
+ {
+ return YetiLevenshtein(p1, s1.Length, p2, s2.Length, 0); // substitutionCost = 1
+ }
+ }
+ public static unsafe int YetiLevenshtein (string s1, string s2, int substitionCost)
+ {
+ var xc = substitionCost - 1;
- public static unsafe int YetiLevenshtein(string s1, string s2)
+ if (xc is < 0 or > 1)
{
- fixed (char* p1 = s1)
- fixed (char* p2 = s2)
- {
- return YetiLevenshtein(p1, s1.Length, p2, s2.Length, 0); // substitutionCost = 1
- }
+ throw new ArgumentException("", nameof(substitionCost));
}
- public static unsafe int YetiLevenshtein(string s1, string s2, int substitionCost)
+ fixed (char* p1 = s1)
+ fixed (char* p2 = s2)
{
- int xc = substitionCost - 1;
- if (xc < 0 || xc > 1)
- {
- throw new ArgumentException("", "substitionCost");
- }
+ return YetiLevenshtein(p1, s1.Length, p2, s2.Length, xc);
+ }
+ }
- fixed (char* p1 = s1)
- fixed (char* p2 = s2)
- {
- return YetiLevenshtein(p1, s1.Length, p2, s2.Length, xc);
- }
+ ///
+ /// Cetin Sert, David Necas
+ /// Source Code
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static unsafe int YetiLevenshtein (char* s1, int l1, char* s2, int l2, int xcost)
+ {
+ int i;
+ //int *row; /* we only need to keep one row of costs */
+ int* end;
+ int half;
+
+ /* strip common prefix */
+ while (l1 > 0 && l2 > 0 && *s1 == *s2)
+ {
+ l1--;
+ l2--;
+ s1++;
+ s2++;
}
- ///
- /// Cetin Sert, David Necas
- /// Source Code
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public static unsafe int YetiLevenshtein(char* s1, int l1, char* s2, int l2, int xcost)
- {
- int i;
- //int *row; /* we only need to keep one row of costs */
- int* end;
- int half;
-
- /* strip common prefix */
- while (l1 > 0 && l2 > 0 && *s1 == *s2)
- {
- l1--;
- l2--;
- s1++;
- s2++;
- }
+ /* strip common suffix */
+ while (l1 > 0 && l2 > 0 && s1[l1 - 1] == s2[l2 - 1])
+ {
+ l1--;
+ l2--;
+ }
- /* strip common suffix */
- while (l1 > 0 && l2 > 0 && s1[l1 - 1] == s2[l2 - 1])
- {
- l1--;
- l2--;
- }
+ /* catch trivial cases */
+ if (l1 == 0)
+ {
+ return l2;
+ }
- /* catch trivial cases */
- if (l1 == 0)
- {
- return l2;
- }
- if (l2 == 0)
- {
- return l1;
- }
+ if (l2 == 0)
+ {
+ return l1;
+ }
- /* make the inner cycle (i.e. string2) the longer one */
- if (l1 > l2)
- {
- int nx = l1;
- char* sx = s1;
- l1 = l2;
- l2 = nx;
- s1 = s2;
- s2 = sx;
- }
+ /* make the inner cycle (i.e. string2) the longer one */
+ if (l1 > l2)
+ {
+ var nx = l1;
+ var sx = s1;
+ l1 = l2;
+ l2 = nx;
+ s1 = s2;
+ s2 = sx;
+ }
- //check len1 == 1 separately
- if (l1 == 1)
- {
- //throw new NotImplementedException();
- if (xcost > 0)
- //return l2 + 1 - 2*(memchr(s2, *s1, l2) != NULL);
- {
- return l2 + 1 - 2 * memchrRPLC(s2, *s1, l2);
- }
- else
- //return l2 - (memchr(s2, *s1, l2) != NULL);
- {
- return l2 - memchrRPLC(s2, *s1, l2);
- }
- }
+ //check len1 == 1 separately
+ if (l1 == 1)
+ {
+ //throw new NotImplementedException();
+ return xcost > 0
+ ? l2 + 1 - (2 * MemchrRPLC(s2, *s1, l2))
+ : l2 - MemchrRPLC(s2, *s1, l2);
+ }
- l1++;
- l2++;
- half = l1 >> 1;
+ l1++;
+ l2++;
+ half = l1 >> 1;
- /* initalize first row */
- //row = (int*)malloc(l2*sizeof(int));
- int* row = stackalloc int[l2];
- if (l2 < 0)
- //if (!row)
- {
- return -1;
- }
- end = row + l2 - 1;
- for (i = 0; i < l2 - (xcost > 0 ? 0 : half); i++)
- {
- row[i] = i;
- }
+ /* initalize first row */
+ //row = (int*)malloc(l2*sizeof(int));
+ var row = stackalloc int[l2];
+
+ if (l2 < 0)
+ //if (!row)
+ {
+ return -1;
+ }
+
+ end = row + l2 - 1;
- /* go through the matrix and compute the costs. yes, this is an extremely
- * obfuscated version, but also extremely memory-conservative and
- * relatively fast.
- */
- if (xcost > 0)
+ for (i = 0; i < l2 - (xcost > 0 ? 0 : half); i++)
+ {
+ row[i] = i;
+ }
+
+ /* go through the matrix and compute the costs. yes, this is an extremely
+ * obfuscated version, but also extremely memory-conservative and
+ * relatively fast.
+ */
+ if (xcost > 0)
+ {
+ for (i = 1; i < l1; i++)
{
- for (i = 1; i < l1; i++)
+ var p = row + 1;
+ var char1 = s1[i - 1];
+ var char2p = s2;
+ var D = i;
+ var x = i;
+
+ while (p <= end)
{
- int* p = row + 1;
- char char1 = s1[i - 1];
- char* char2p = s2;
- int D = i;
- int x = i;
- while (p <= end)
+ if (char1 == *char2p++)
{
- if (char1 == *char2p++)
- {
- x = --D;
- }
- else
- {
- x++;
- }
- D = *p;
- D++;
- if (x > D)
- {
- x = D;
- }
- *p++ = x;
+ x = --D;
}
+ else
+ {
+ x++;
+ }
+
+ D = *p;
+ D++;
+
+ if (x > D)
+ {
+ x = D;
+ }
+
+ *p++ = x;
}
}
- else
- {
- /* in this case we don't have to scan two corner triangles (of size len1/2)
- * in the matrix because no best path can go throught them. note this
- * breaks when len1 == len2 == 2 so the memchr() special case above is
- * necessary */
- row[0] = l1 - half - 1;
- for (i = 1; i < l1; i++)
+ }
+ else
+ {
+ /* in this case we don't have to scan two corner triangles (of size len1/2)
+ * in the matrix because no best path can go throught them. note this
+ * breaks when len1 == len2 == 2 so the memchr() special case above is
+ * necessary */
+ row[0] = l1 - half - 1;
+ for (i = 1; i < l1; i++)
+ {
+ int* p;
+ var char1 = s1[i - 1];
+ char* char2p;
+ int D, x;
+
+ /* skip the upper triangle */
+ if (i >= l1 - half)
{
- int* p;
- char char1 = s1[i - 1];
- char* char2p;
- int D, x;
- /* skip the upper triangle */
- if (i >= l1 - half)
- {
- int offset = i - (l1 - half);
- int c3;
+ var offset = i - (l1 - half);
+ int c3;
- char2p = s2 + offset;
- p = row + offset;
- c3 = *p++ + (char1 != *char2p++ ? 1 : 0);
- x = *p;
- x++;
- D = x;
- if (x > c3)
- {
- x = c3;
- }
- *p++ = x;
- }
- else
+ char2p = s2 + offset;
+ p = row + offset;
+ c3 = *p++ + (char1 != *char2p++ ? 1 : 0);
+ x = *p;
+ x++;
+ D = x;
+
+ if (x > c3)
{
- p = row + 1;
- char2p = s2;
- D = x = i;
+ x = c3;
}
- /* skip the lower triangle */
- if (i <= half + 1)
+
+ *p++ = x;
+ }
+ else
+ {
+ p = row + 1;
+ char2p = s2;
+ D = x = i;
+ }
+
+ /* skip the lower triangle */
+ if (i <= half + 1)
+ {
+ end = row + l2 + i - half - 2;
+ }
+
+ /* main */
+ while (p <= end)
+ {
+ var c3 = --D + (char1 != *char2p++ ? 1 : 0);
+ x++;
+
+ if (x > c3)
{
- end = row + l2 + i - half - 2;
+ x = c3;
}
- /* main */
- while (p <= end)
+
+ D = *p;
+ D++;
+
+ if (x > D)
{
- int c3 = --D + (char1 != *char2p++ ? 1 : 0);
- x++;
- if (x > c3)
- {
- x = c3;
- }
- D = *p;
- D++;
- if (x > D)
- {
- x = D;
- }
- *p++ = x;
+ x = D;
}
- /* lower triangle sentinel */
- if (i <= half)
+
+ *p++ = x;
+ }
+
+ /* lower triangle sentinel */
+ if (i <= half)
+ {
+ var c3 = --D + (char1 != *char2p ? 1 : 0);
+ x++;
+ if (x > c3)
{
- int c3 = --D + (char1 != *char2p ? 1 : 0);
- x++;
- if (x > c3)
- {
- x = c3;
- }
- *p = x;
+ x = c3;
}
+
+ *p = x;
}
}
-
- i = *end;
- return i;
}
- ///
- /// Returns true, if the given string is null or empty
- ///
- ///
- ///
- public static bool IsNull(string toTest)
+ i = *end;
+ return i;
+ }
+
+ ///
+ /// Returns true, if the given string is null or empty
+ ///
+ ///
+ ///
+ public static bool IsNull (string toTest)
+ {
+ return toTest == null || toTest.Length == 0;
+ }
+
+ ///
+ /// Returns true, if the given string is null or empty or contains only spaces
+ ///
+ ///
+ ///
+ public static bool IsNullOrSpaces (string toTest)
+ {
+ return toTest == null || toTest.Trim().Length == 0;
+ }
+
+ [Conditional("DEBUG")]
+ public static void AssertTrue (bool condition, string msg)
+ {
+ if (!condition)
{
- return toTest == null || toTest.Length == 0;
+ //Todo this should be done differently
+ //MessageBox.Show("Assertion: " + msg);
+ throw new Exception(msg);
}
+ }
- ///
- /// Returns true, if the given string is null or empty or contains only spaces
- ///
- ///
- ///
- public static bool IsNullOrSpaces(string toTest)
+ //TODO Add Null Check (https://github.com/LogExperts/LogExpert/issues/403)
+ [SupportedOSPlatform("windows")]
+ public string? GetWordFromPos (int xPos, string text, Graphics g, Font font)
+ {
+ var words = text.Split([' ', '.', ':', ';']);
+
+ var index = 0;
+
+ List crList = [];
+
+ for (var i = 0; i < words.Length; ++i)
{
- return toTest == null || toTest.Trim().Length == 0;
+ crList.Add(new CharacterRange(index, words[i].Length));
+ index += words[i].Length;
}
- [Conditional("DEBUG")]
- public static void AssertTrue(bool condition, string msg)
+ CharacterRange[] crArray = [.. crList];
+
+ StringFormat stringFormat = new(StringFormat.GenericTypographic)
{
- if (!condition)
+ Trimming = StringTrimming.None,
+ FormatFlags = StringFormatFlags.NoClip
+ };
+
+ stringFormat.SetMeasurableCharacterRanges(crArray);
+
+ RectangleF rect = new(0, 0, 3000, 20);
+ Region[] stringRegions = g.MeasureCharacterRanges(text, font, rect, stringFormat);
+
+ var found = false;
+
+ var y = 0;
+
+ foreach (Region regio in stringRegions)
+ {
+ if (regio.IsVisible(xPos, 3, g))
{
- //Todo this should be done differently
- //MessageBox.Show("Assertion: " + msg);
- throw new Exception(msg);
+ found = true;
+ break;
}
+
+ y++;
}
- #endregion
+ return found
+ ? words[y]
+ : null;
+ }
- #region Private Methods
+ #endregion
- private static bool TestFilterMatch(FilterParams filterParams, ILogLine line, ILogLineColumnizerCallback columnizerCallback)
- {
- string lowerSearchText;
- string searchText;
- Regex rex;
+ #region Private Methods
- if (filterParams.IsInRange)
- {
- lowerSearchText = filterParams.LowerRangeSearchText;
- searchText = filterParams.RangeSearchText;
- rex = filterParams.RangeRex;
- }
- else
- {
- lowerSearchText = filterParams.LowerSearchText;
- searchText = filterParams.SearchText;
- rex = filterParams.Rex;
- }
+ private static bool TestFilterMatch (FilterParams filterParams, ILogLine line, ILogLineColumnizerCallback columnizerCallback)
+ {
+ string lowerSearchText;
+ string searchText;
+ Regex rex;
- if (searchText == null || lowerSearchText == null || searchText.Length == 0)
- {
- return false;
- }
+ if (filterParams.IsInRange)
+ {
+ lowerSearchText = filterParams.LowerRangeSearchText;
+ searchText = filterParams.RangeSearchText;
+ rex = filterParams.RangeRex;
+ }
+ else
+ {
+ lowerSearchText = filterParams.LowerSearchText;
+ searchText = filterParams.SearchText;
+ rex = filterParams.Rex;
+ }
+
+ if (searchText == null || lowerSearchText == null || searchText.Length == 0)
+ {
+ return false;
+ }
- if (filterParams.ColumnRestrict)
+ if (filterParams.ColumnRestrict)
+ {
+ IColumnizedLogLine columns = filterParams.CurrentColumnizer.SplitLine(columnizerCallback, line);
+ var found = false;
+ foreach (var colIndex in filterParams.ColumnList)
{
- IColumnizedLogLine columns = filterParams.CurrentColumnizer.SplitLine(columnizerCallback, line);
- bool found = false;
- foreach (int colIndex in filterParams.ColumnList)
+ if (colIndex < columns.ColumnValues.Length
+ ) // just to be sure, maybe the columnizer has changed anyhow
{
- if (colIndex < columns.ColumnValues.Length
- ) // just to be sure, maybe the columnizer has changed anyhow
+ if (columns.ColumnValues[colIndex].FullValue.Trim().Length == 0)
{
- if (columns.ColumnValues[colIndex].FullValue.Trim().Length == 0)
+ if (filterParams.EmptyColumnUsePrev)
{
- if (filterParams.EmptyColumnUsePrev)
+ var prevValue = (string)filterParams.LastNonEmptyCols[colIndex];
+ if (prevValue != null)
{
- string prevValue = (string)filterParams.LastNonEmptyCols[colIndex];
- if (prevValue != null)
+ if (TestMatchSub(filterParams, prevValue, lowerSearchText, searchText, rex,
+ filterParams.ExactColumnMatch))
{
- if (TestMatchSub(filterParams, prevValue, lowerSearchText, searchText, rex,
- filterParams.ExactColumnMatch))
- {
- found = true;
- }
+ found = true;
}
}
- else if (filterParams.EmptyColumnHit)
- {
- return true;
- }
}
- else
+ else if (filterParams.EmptyColumnHit)
{
- filterParams.LastNonEmptyCols[colIndex] = columns.ColumnValues[colIndex].FullValue;
- if (TestMatchSub(filterParams, columns.ColumnValues[colIndex].FullValue, lowerSearchText,
- searchText, rex,
- filterParams.ExactColumnMatch))
- {
- found = true;
- }
+ return true;
+ }
+ }
+ else
+ {
+ filterParams.LastNonEmptyCols[colIndex] = columns.ColumnValues[colIndex].FullValue;
+ if (TestMatchSub(filterParams, columns.ColumnValues[colIndex].FullValue, lowerSearchText,
+ searchText, rex,
+ filterParams.ExactColumnMatch))
+ {
+ found = true;
}
}
}
- return found;
}
- else
+
+ return found;
+ }
+ else
+ {
+ return TestMatchSub(filterParams, line.FullLine, lowerSearchText, searchText, rex, false);
+ }
+ }
+
+ private static bool TestMatchSub (FilterParams filterParams, string line, string lowerSearchText, string searchText, Regex rex, bool exactMatch)
+ {
+ if (filterParams.IsRegex)
+ {
+ if (rex.IsMatch(line))
{
- return TestMatchSub(filterParams, line.FullLine, lowerSearchText, searchText, rex, false);
+ return true;
}
}
-
- private static bool TestMatchSub(FilterParams filterParams, string line, string lowerSearchText, string searchText, Regex rex, bool exactMatch)
+ else
{
- if (filterParams.IsRegex)
+ if (!filterParams.IsCaseSensitive)
{
- if (rex.IsMatch(line))
+ if (exactMatch)
{
- return true;
+ if (line.ToLower().Trim().Equals(lowerSearchText))
+ {
+ return true;
+ }
+ }
+ else
+ {
+ if (line.Contains(lowerSearchText, StringComparison.CurrentCultureIgnoreCase))
+ {
+ return true;
+ }
}
}
else
{
- if (!filterParams.IsCaseSensitive)
+ if (exactMatch)
{
- if (exactMatch)
+ if (line.Equals(searchText))
{
- if (line.ToLower().Trim().Equals(lowerSearchText))
- {
- return true;
- }
- }
- else
- {
- if (line.Contains(lowerSearchText, StringComparison.CurrentCultureIgnoreCase))
- {
- return true;
- }
+ return true;
}
}
else
{
- if (exactMatch)
- {
- if (line.Equals(searchText))
- {
- return true;
- }
- }
- else
+ if (line.Contains(searchText))
{
- if (line.Contains(searchText))
- {
- return true;
- }
+ return true;
}
}
+ }
- if (filterParams.FuzzyValue > 0)
+ if (filterParams.FuzzyValue > 0)
+ {
+ var range = line.Length - searchText.Length;
+ if (range > 0)
{
- int range = line.Length - searchText.Length;
- if (range > 0)
+ for (var i = 0; i < range; ++i)
{
- for (int i = 0; i < range; ++i)
- {
- string src = line.Substring(i, searchText.Length);
+ var src = line.Substring(i, searchText.Length);
- if (!filterParams.IsCaseSensitive)
- {
- src = src.ToLower();
- }
+ if (!filterParams.IsCaseSensitive)
+ {
+ src = src.ToLower();
+ }
- int dist = DamerauLevenshteinDistance(src, searchText);
+ var dist = DamerauLevenshteinDistance(src, searchText);
- if ((searchText.Length + 1) / (float)(dist + 1) >= 11F / (float)(filterParams.FuzzyValue + 1F))
- {
- return true;
- }
+ if ((searchText.Length + 1) / (float)(dist + 1) >= 11F / (float)(filterParams.FuzzyValue + 1F))
+ {
+ return true;
}
}
- return false;
}
+ return false;
}
- return false;
}
+ return false;
+ }
- private static unsafe int memchrRPLC(char* buffer, char c, int count)
+ private static unsafe int MemchrRPLC (char* buffer, char c, int count)
+ {
+ var p = buffer;
+ var e = buffer + count;
+
+ while (p++ < e)
{
- char* p = buffer;
- char* e = buffer + count;
- while (p++ < e)
+ if (*p == c)
{
- if (*p == c)
- {
- return 1;
- }
+ return 1;
}
- return 0;
}
- #endregion
+ return 0;
}
+
+ #endregion
}
\ No newline at end of file
diff --git a/src/LogExpert.Core/Interface/IBookmarkView.cs b/src/LogExpert.Core/Interface/IBookmarkView.cs
deleted file mode 100644
index f626c004..00000000
--- a/src/LogExpert.Core/Interface/IBookmarkView.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using LogExpert.Core.Entities;
-
-namespace LogExpert.Core.Interface
-{
- ///
- /// To be implemented by the bookmark window. Will be informed from LogWindow about changes in bookmarks.
- ///
- //TODO: Not in use!
- public interface IBookmarkView
- {
- #region Properties
-
- bool LineColumnVisible { set; }
-
- #endregion
-
- #region Public methods
-
- void UpdateView();
-
- void BookmarkTextChanged(Bookmark bookmark);
-
- void SelectBookmark(int lineNum);
-
- void SetBookmarkData(IBookmarkData bookmarkData);
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/src/LogExpert.Core/Interface/ILogTabWindow.cs b/src/LogExpert.Core/Interface/ILogTabWindow.cs
index 518b3c01..822d464d 100644
--- a/src/LogExpert.Core/Interface/ILogTabWindow.cs
+++ b/src/LogExpert.Core/Interface/ILogTabWindow.cs
@@ -1,15 +1,14 @@
-namespace LogExpert.Core.Interface
+namespace LogExpert.Core.Interface;
+
+//TODO: Add documentation
+public interface ILogTabWindow
{
- //TODO: Add documentation
- public interface ILogTabWindow
- {
- ILogExpertProxy LogExpertProxy { get; set; }
- bool IsDisposed { get; }
+ ILogExpertProxy LogExpertProxy { get; set; }
+ bool IsDisposed { get; }
- void Activate();
- object Invoke(Delegate method, params object?[]? objects);
- void LoadFiles(string[] fileNames);
- void SetForeground();
- void Show();
- }
+ void Activate ();
+ object Invoke (Delegate method, params object?[]? objects);
+ void LoadFiles (string[] fileNames);
+ void SetForeground ();
+ void Show ();
}
\ No newline at end of file
diff --git a/src/LogExpert.Core/Interface/ILogWindow.cs b/src/LogExpert.Core/Interface/ILogWindow.cs
index abe821b3..9072cdcb 100644
--- a/src/LogExpert.Core/Interface/ILogWindow.cs
+++ b/src/LogExpert.Core/Interface/ILogWindow.cs
@@ -1,30 +1,43 @@
-
+
using LogExpert.Core.Classes.Log;
using LogExpert.Core.Classes.Persister;
-using LogExpert.Core.Entities;
using LogExpert.Core.EventHandlers;
-using static LogExpert.Core.Classes.Log.LogfileReader;
-namespace LogExpert.Core.Interface
+namespace LogExpert.Core.Interface;
+
+//TODO: Add documentation
+public interface ILogWindow
{
- //TODO: Add documentation
- public interface ILogWindow
- {
- string GetCurrentFileName(int lineNum);
- ILogLine GetLine(int lineNum);
- DateTime GetTimestampForLineForward(ref int lineNum, bool v);
- DateTime GetTimestampForLine(ref int lastLineNum, bool v);
- int FindTimestampLine_Internal(int lineNum1, int lineNum2, int lastLineNum, DateTime searchTimeStamp, bool v);
- void SelectLine(int lineNum, bool v1, bool v2);
- PersistenceData GetPersistenceData();
- void AddTempFileTab(string fileName, string title);
- void WritePipeTab(IList lineEntryList, string title);
- void Activate();
- LogfileReader _logFileReader { get; }
- string Text { get; }
- string FileName { get; }
- event FileSizeChangedEventHandler FileSizeChanged; //TODO: All handlers should be moved to Core
- event EventHandler TailFollowed;
- //LogExpert.UI.Controls.LogTabWindow.LogTabWindow.LogWindowData Tag { get; }
- }
+ string GetCurrentFileName (int lineNum);
+
+ ILogLine GetLine (int lineNum);
+
+ //TODO Find a way to not use a referenced int (https://github.com/LogExperts/LogExpert/issues/404)
+ DateTime GetTimestampForLineForward (ref int lineNum, bool v);
+
+ //TODO Find a way to not use a referenced int (https://github.com/LogExperts/LogExpert/issues/404)
+ DateTime GetTimestampForLine (ref int lastLineNum, bool v);
+
+ int FindTimestampLine_Internal (int lineNum1, int lineNum2, int lastLineNum, DateTime searchTimeStamp, bool v);
+
+ void SelectLine (int lineNum, bool v1, bool v2);
+
+ PersistenceData GetPersistenceData ();
+
+ void AddTempFileTab (string fileName, string title);
+
+ void WritePipeTab (IList lineEntryList, string title);
+
+ void Activate ();
+
+ LogfileReader LogFileReader { get; }
+
+ string Text { get; }
+
+ string FileName { get; }
+
+ event FileSizeChangedEventHandler FileSizeChanged; //TODO: All handlers should be moved to Core
+
+ event EventHandler TailFollowed;
+ //LogExpert.UI.Controls.LogTabWindow.LogTabWindow.LogWindowData Tag { get; }
}
\ No newline at end of file
diff --git a/src/LogExpert.Core/LogExpert.Core.csproj b/src/LogExpert.Core/LogExpert.Core.csproj
index 0062fbbf..c922c133 100644
--- a/src/LogExpert.Core/LogExpert.Core.csproj
+++ b/src/LogExpert.Core/LogExpert.Core.csproj
@@ -23,6 +23,7 @@
+
diff --git a/src/LogExpert.UI/Controls/LogWindow/ColumnCache.cs b/src/LogExpert.UI/Controls/LogWindow/ColumnCache.cs
index 4d735027..2ac878a7 100644
--- a/src/LogExpert.UI/Controls/LogWindow/ColumnCache.cs
+++ b/src/LogExpert.UI/Controls/LogWindow/ColumnCache.cs
@@ -1,40 +1,41 @@
-using LogExpert.Classes.ILogLineColumnizerCallback;
+using LogExpert.Core.Callback;
using LogExpert.Core.Classes.Log;
-namespace LogExpert.UI.Controls.LogWindow
+namespace LogExpert.UI.Controls.LogWindow;
+
+internal class ColumnCache
{
- internal class ColumnCache
- {
- #region Fields
+ #region Fields
- private IColumnizedLogLine _cachedColumns;
- private ILogLineColumnizer _lastColumnizer;
- private int _lastLineNumber = -1;
+ private IColumnizedLogLine _cachedColumns;
+ private ILogLineColumnizer _lastColumnizer;
+ private int _lastLineNumber = -1;
- #endregion
+ #endregion
- #region Internals
+ #region Internals
- internal IColumnizedLogLine GetColumnsForLine(LogfileReader logFileReader, int lineNumber, ILogLineColumnizer columnizer, ColumnizerCallback columnizerCallback)
+ internal IColumnizedLogLine GetColumnsForLine (LogfileReader logFileReader, int lineNumber, ILogLineColumnizer columnizer, ColumnizerCallback columnizerCallback)
+ {
+ if (_lastColumnizer != columnizer || (_lastLineNumber != lineNumber && _cachedColumns != null) || columnizerCallback.GetLineNum() != lineNumber)
{
- if (_lastColumnizer != columnizer || _lastLineNumber != lineNumber && _cachedColumns != null || columnizerCallback.LineNum != lineNumber)
+ _lastColumnizer = columnizer;
+ _lastLineNumber = lineNumber;
+ ILogLine line = logFileReader.GetLogLineWithWait(lineNumber).Result;
+
+ if (line != null)
{
- _lastColumnizer = columnizer;
- _lastLineNumber = lineNumber;
- ILogLine line = logFileReader.GetLogLineWithWait(lineNumber).Result;
- if (line != null)
- {
- columnizerCallback.LineNum = lineNumber;
- _cachedColumns = columnizer.SplitLine(columnizerCallback, line);
- }
- else
- {
- _cachedColumns = null;
- }
+ columnizerCallback.SetLineNum(lineNumber);
+ _cachedColumns = columnizer.SplitLine(columnizerCallback, line);
+ }
+ else
+ {
+ _cachedColumns = null;
}
- return _cachedColumns;
}
- #endregion
+ return _cachedColumns;
}
+
+ #endregion
}
\ No newline at end of file
diff --git a/src/LogExpert.UI/Controls/LogWindow/LogExpertCallback.cs b/src/LogExpert.UI/Controls/LogWindow/LogExpertCallback.cs
index d3de849b..a42320d0 100644
--- a/src/LogExpert.UI/Controls/LogWindow/LogExpertCallback.cs
+++ b/src/LogExpert.UI/Controls/LogWindow/LogExpertCallback.cs
@@ -1,26 +1,25 @@
-using LogExpert.Classes.ILogLineColumnizerCallback;
+using LogExpert.Core.Callback;
-namespace LogExpert.UI.Controls.LogWindow
-{
- internal class LogExpertCallback(LogWindow logWindow) : ColumnizerCallback(logWindow), ILogExpertCallback
- {
- #region Public methods
+namespace LogExpert.UI.Controls.LogWindow;
- public void AddTempFileTab(string fileName, string title)
- {
- _logWindow.AddTempFileTab(fileName, title);
- }
+internal class LogExpertCallback (LogWindow logWindow) : ColumnizerCallback(logWindow), ILogExpertCallback
+{
+ #region Public methods
- public void AddPipedTab(IList lineEntryList, string title)
- {
- _logWindow.WritePipeTab(lineEntryList, title);
- }
+ public void AddTempFileTab (string fileName, string title)
+ {
+ LogWindow.AddTempFileTab(fileName, title);
+ }
- public string GetTabTitle()
- {
- return _logWindow.Text;
- }
+ public void AddPipedTab (IList lineEntryList, string title)
+ {
+ LogWindow.WritePipeTab(lineEntryList, title);
+ }
- #endregion
+ public string GetTabTitle ()
+ {
+ return LogWindow.Text;
}
+
+ #endregion
}
diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs
index a3aa74ca..9cd0514e 100644
--- a/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs
+++ b/src/LogExpert.UI/Controls/LogWindow/LogWindow.cs
@@ -1,5 +1,5 @@
-using LogExpert.Classes.Filter;
-using LogExpert.Classes.ILogLineColumnizerCallback;
+using LogExpert.Classes.Filter;
+using LogExpert.Core.Callback;
using LogExpert.Core.Classes.Bookmark;
using LogExpert.Core.Classes.Filter;
using LogExpert.Core.Classes.Highlight;
@@ -11,693 +11,693 @@
using LogExpert.Core.EventHandlers;
using LogExpert.Core.Interface;
using LogExpert.Dialogs;
-using LogExpert.UI.Controls.LogTabWindow;
using LogExpert.UI.Dialogs;
using LogExpert.UI.Extensions.Forms;
using LogExpert.UI.Interface;
+
using NLog;
+
using WeifenLuo.WinFormsUI.Docking;
//using static LogExpert.PluginRegistry.PluginRegistry; //TODO: Adjust the instance name so using static can be used.
-namespace LogExpert.UI.Controls.LogWindow
-{
- //TODO: Implemented 4 interfaces explicitly. Find them by searcginh: ILogWindow.
- internal partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, ILogWindow
- {
- #region Fields
+namespace LogExpert.UI.Controls.LogWindow;
- private const int SPREAD_MAX = 99;
- private const int PROGRESS_BAR_MODULO = 1000;
- private const int FILTER_ADVANCED_SPLITTER_DISTANCE = 150;
- private static readonly ILogger _logger = LogManager.GetCurrentClassLogger();
+//TODO: Implemented 4 interfaces explicitly. Find them by searching: ILogWindow.
+public partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, ILogWindow
+{
+ #region Fields
- private readonly Image _advancedButtonImage;
+ private const int SPREAD_MAX = 99;
+ private const int PROGRESS_BAR_MODULO = 1000;
+ private const int FILTER_ADVANCED_SPLITTER_DISTANCE = 150;
+ private static readonly ILogger _logger = LogManager.GetCurrentClassLogger();
- private readonly object _bookmarkLock = new();
- private readonly BookmarkDataProvider _bookmarkProvider = new();
+ private readonly Image _advancedButtonImage;
- private readonly IList _cancelHandlerList = new List();
+ private readonly object _bookmarkLock = new();
+ private readonly BookmarkDataProvider _bookmarkProvider = new();
- private readonly object _currentColumnizerLock = new();
+ private readonly IList _cancelHandlerList = new List();
- private readonly object _currentHighlightGroupLock = new();
+ private readonly object _currentColumnizerLock = new();
- private readonly EventWaitHandle _externaLoadingFinishedEvent = new ManualResetEvent(false);
+ private readonly object _currentHighlightGroupLock = new();
- private readonly IList _filterPipeList = new List();
- private readonly Dictionary _freezeStateMap = [];
- private readonly GuiStateArgs _guiStateArgs = new();
+ private readonly EventWaitHandle _externaLoadingFinishedEvent = new ManualResetEvent(false);
- private readonly List _lineHashList = [];
+ private readonly IList _filterPipeList = new List();
+ private readonly Dictionary _freezeStateMap = [];
+ private readonly GuiStateArgs _guiStateArgs = new();
- private readonly EventWaitHandle _loadingFinishedEvent = new ManualResetEvent(false);
+ private readonly List _lineHashList = [];
- private readonly EventWaitHandle _logEventArgsEvent = new ManualResetEvent(false);
+ private readonly EventWaitHandle _loadingFinishedEvent = new ManualResetEvent(false);
- private readonly List _logEventArgsList = [];
- private readonly Task _logEventHandlerTask;
- //private readonly Thread _logEventHandlerThread;
- private readonly Image _panelCloseButtonImage;
+ private readonly EventWaitHandle _logEventArgsEvent = new ManualResetEvent(false);
- private readonly Image _panelOpenButtonImage;
- private readonly LogTabWindow.LogTabWindow _parentLogTabWin;
+ private readonly List _logEventArgsList = [];
+ private readonly Task _logEventHandlerTask;
+ //private readonly Thread _logEventHandlerThread;
+ private readonly Image _panelCloseButtonImage;
- private readonly ProgressEventArgs _progressEventArgs = new();
- private readonly object _reloadLock = new();
- private readonly Image _searchButtonImage;
- private readonly StatusLineEventArgs _statusEventArgs = new();
+ private readonly Image _panelOpenButtonImage;
+ private readonly LogTabWindow.LogTabWindow _parentLogTabWin;
- private readonly object _tempHighlightEntryListLock = new();
+ private readonly ProgressEventArgs _progressEventArgs = new();
+ private readonly object _reloadLock = new();
+ private readonly Image _searchButtonImage;
+ private readonly StatusLineEventArgs _statusEventArgs = new();
- private readonly Task _timeShiftSyncTask;
- private readonly CancellationTokenSource cts = new();
+ private readonly object _tempHighlightEntryListLock = new();
- //private readonly Thread _timeShiftSyncThread;
- private readonly EventWaitHandle _timeShiftSyncTimerEvent = new ManualResetEvent(false);
- private readonly EventWaitHandle _timeShiftSyncWakeupEvent = new ManualResetEvent(false);
+ private readonly Task _timeShiftSyncTask;
+ private readonly CancellationTokenSource cts = new();
- private readonly TimeSpreadCalculator _timeSpreadCalc;
+ //private readonly Thread _timeShiftSyncThread;
+ private readonly EventWaitHandle _timeShiftSyncTimerEvent = new ManualResetEvent(false);
+ private readonly EventWaitHandle _timeShiftSyncWakeupEvent = new ManualResetEvent(false);
- private readonly object _timeSyncListLock = new();
+ private readonly TimeSpreadCalculator _timeSpreadCalc;
- private ColumnCache _columnCache = new();
+ private readonly object _timeSyncListLock = new();
- private ILogLineColumnizer _currentColumnizer;
+ private ColumnCache _columnCache = new();
- //List currentHilightEntryList = new List();
- private HighlightGroup _currentHighlightGroup = new();
+ private ILogLineColumnizer _currentColumnizer;
- private SearchParams _currentSearchParams;
+ //List currentHilightEntryList = new List();
+ private HighlightGroup _currentHighlightGroup = new();
- private string[] _fileNames;
- private List _filterHitList = [];
- private FilterParams _filterParams = new();
- private int _filterPipeNameCounter = 0;
- private List _filterResultList = [];
+ private SearchParams _currentSearchParams;
- private EventWaitHandle _filterUpdateEvent = new ManualResetEvent(false);
+ private string[] _fileNames;
+ private List _filterHitList = [];
+ private FilterParams _filterParams = new();
+ private int _filterPipeNameCounter = 0;
+ private List _filterResultList = [];
- private ILogLineColumnizer _forcedColumnizer;
- private ILogLineColumnizer _forcedColumnizerForLoading;
- private bool _isDeadFile;
- private bool _isErrorShowing;
- private bool _isLoadError;
- private bool _isLoading;
- private bool _isMultiFile;
- private bool _isSearching;
- private bool _isTimestampDisplaySyncing;
- private List _lastFilterLinesList = [];
+ private EventWaitHandle _filterUpdateEvent = new ManualResetEvent(false);
- private int _lineHeight = 0;
+ private ILogLineColumnizer _forcedColumnizer;
+ private ILogLineColumnizer _forcedColumnizerForLoading;
+ private bool _isDeadFile;
+ private bool _isErrorShowing;
+ private bool _isLoadError;
+ private bool _isLoading;
+ private bool _isMultiFile;
+ private bool _isSearching;
+ private bool _isTimestampDisplaySyncing;
+ private List _lastFilterLinesList = [];
- internal LogfileReader _logFileReader;
- private MultiFileOptions _multiFileOptions = new();
- private bool _noSelectionUpdates;
- private PatternArgs _patternArgs = new();
- private PatternWindow _patternWindow;
+ private int _lineHeight = 0;
- private ReloadMemento _reloadMemento;
- private int _reloadOverloadCounter = 0;
- private SortedList _rowHeightList = [];
- private int _selectedCol = 0; // set by context menu event for column headers only
- private bool _shouldCallTimeSync;
- private bool _shouldCancel;
- private bool _shouldTimestampDisplaySyncingCancel;
- private bool _showAdvanced;
- private List _tempHighlightEntryList = [];
- private int _timeShiftSyncLine = 0;
+ internal LogfileReader _logFileReader;
+ private MultiFileOptions _multiFileOptions = new();
+ private bool _noSelectionUpdates;
+ private PatternArgs _patternArgs = new();
+ private PatternWindow _patternWindow;
- private bool _waitingForClose;
+ private ReloadMemento _reloadMemento;
+ private int _reloadOverloadCounter = 0;
+ private SortedList _rowHeightList = [];
+ private int _selectedCol = 0; // set by context menu event for column headers only
+ private bool _shouldCallTimeSync;
+ private bool _shouldCancel;
+ private bool _shouldTimestampDisplaySyncingCancel;
+ private bool _showAdvanced;
+ private List _tempHighlightEntryList = [];
+ private int _timeShiftSyncLine = 0;
- #endregion
+ private bool _waitingForClose;
- #region cTor
+ #endregion
- public LogWindow(LogTabWindow.LogTabWindow parent, string fileName, bool isTempFile, bool forcePersistenceLoading, IConfigManager configManager)
- {
- SuspendLayout();
+ #region cTor
- AutoScaleDimensions = new SizeF(96F, 96F);
- AutoScaleMode = AutoScaleMode.Dpi;
+ public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTempFile, bool forcePersistenceLoading, IConfigManager configManager)
+ {
+ SuspendLayout();
- InitializeComponent(); //TODO: Move this to be the first line of the constructor?
+ AutoScaleDimensions = new SizeF(96F, 96F);
+ AutoScaleMode = AutoScaleMode.Dpi;
- CreateDefaultViewStyle();
+ InitializeComponent(); //TODO: Move this to be the first line of the constructor?
- columnNamesLabel.Text = ""; // no filtering on columns by default
+ CreateDefaultViewStyle();
- _parentLogTabWin = parent;
- IsTempFile = isTempFile;
- ConfigManager = configManager; //TODO: This should be changed to DI
- //Thread.CurrentThread.Name = "LogWindowThread";
- ColumnizerCallbackObject = new ColumnizerCallback(this);
+ columnNamesLabel.Text = ""; // no filtering on columns by default
- FileName = fileName;
- ForcePersistenceLoading = forcePersistenceLoading;
+ _parentLogTabWin = parent;
+ IsTempFile = isTempFile;
+ ConfigManager = configManager; //TODO: This should be changed to DI
+ //Thread.CurrentThread.Name = "LogWindowThread";
+ ColumnizerCallbackObject = new ColumnizerCallback(this);
- dataGridView.CellValueNeeded += OnDataGridViewCellValueNeeded;
- dataGridView.CellPainting += OnDataGridView_CellPainting;
+ FileName = fileName;
+ ForcePersistenceLoading = forcePersistenceLoading;
- filterGridView.CellValueNeeded += OnFilterGridViewCellValueNeeded;
- filterGridView.CellPainting += OnFilterGridViewCellPainting;
- filterListBox.DrawMode = DrawMode.OwnerDrawVariable;
- filterListBox.MeasureItem += MeasureItem;
+ dataGridView.CellValueNeeded += OnDataGridViewCellValueNeeded;
+ dataGridView.CellPainting += OnDataGridView_CellPainting;
- Closing += OnLogWindowClosing;
- Disposed += OnLogWindowDisposed;
- Load += OnLogWindowLoad;
+ filterGridView.CellValueNeeded += OnFilterGridViewCellValueNeeded;
+ filterGridView.CellPainting += OnFilterGridViewCellPainting;
+ filterListBox.DrawMode = DrawMode.OwnerDrawVariable;
+ filterListBox.MeasureItem += MeasureItem;
- _timeSpreadCalc = new TimeSpreadCalculator(this);
- timeSpreadingControl.TimeSpreadCalc = _timeSpreadCalc;
- timeSpreadingControl.LineSelected += OnTimeSpreadingControlLineSelected;
- tableLayoutPanel1.ColumnStyles[1].SizeType = SizeType.Absolute;
- tableLayoutPanel1.ColumnStyles[1].Width = 20;
- tableLayoutPanel1.ColumnStyles[0].SizeType = SizeType.Percent;
- tableLayoutPanel1.ColumnStyles[0].Width = 100;
+ Closing += OnLogWindowClosing;
+ Disposed += OnLogWindowDisposed;
+ Load += OnLogWindowLoad;
- _parentLogTabWin.HighlightSettingsChanged += OnParentHighlightSettingsChanged;
- SetColumnizer(PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers[0]);
+ _timeSpreadCalc = new TimeSpreadCalculator(this);
+ timeSpreadingControl.TimeSpreadCalc = _timeSpreadCalc;
+ timeSpreadingControl.LineSelected += OnTimeSpreadingControlLineSelected;
+ tableLayoutPanel1.ColumnStyles[1].SizeType = SizeType.Absolute;
+ tableLayoutPanel1.ColumnStyles[1].Width = 20;
+ tableLayoutPanel1.ColumnStyles[0].SizeType = SizeType.Percent;
+ tableLayoutPanel1.ColumnStyles[0].Width = 100;
- _patternArgs.MaxMisses = 5;
- _patternArgs.MinWeight = 1;
- _patternArgs.MaxDiffInBlock = 5;
- _patternArgs.Fuzzy = 5;
+ _parentLogTabWin.HighlightSettingsChanged += OnParentHighlightSettingsChanged;
+ SetColumnizer(PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers[0]);
- //InitPatternWindow();
+ _patternArgs.MaxMisses = 5;
+ _patternArgs.MinWeight = 1;
+ _patternArgs.MaxDiffInBlock = 5;
+ _patternArgs.Fuzzy = 5;
- //this.toolwinTabControl.TabPages.Add(this.patternWindow);
- //this.toolwinTabControl.TabPages.Add(this.bookmarkWindow);
+ //InitPatternWindow();
- _filterParams = new FilterParams();
- foreach (string item in configManager.Settings.filterHistoryList)
- {
- filterComboBox.Items.Add(item);
- }
+ //this.toolwinTabControl.TabPages.Add(this.patternWindow);
+ //this.toolwinTabControl.TabPages.Add(this.bookmarkWindow);
- filterComboBox.DropDownHeight = filterComboBox.ItemHeight * configManager.Settings.Preferences.maximumFilterEntriesDisplayed;
- AutoResizeFilterBox();
+ _filterParams = new FilterParams();
+ foreach (string item in configManager.Settings.filterHistoryList)
+ {
+ filterComboBox.Items.Add(item);
+ }
- filterRegexCheckBox.Checked = _filterParams.IsRegex;
- filterCaseSensitiveCheckBox.Checked = _filterParams.IsCaseSensitive;
- filterTailCheckBox.Checked = _filterParams.IsFilterTail;
+ filterComboBox.DropDownHeight = filterComboBox.ItemHeight * configManager.Settings.Preferences.maximumFilterEntriesDisplayed;
+ AutoResizeFilterBox();
- splitContainerLogWindow.Panel2Collapsed = true;
- advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE;
+ filterRegexCheckBox.Checked = _filterParams.IsRegex;
+ filterCaseSensitiveCheckBox.Checked = _filterParams.IsCaseSensitive;
+ filterTailCheckBox.Checked = _filterParams.IsFilterTail;
- _timeShiftSyncTask = new Task(SyncTimestampDisplayWorker, cts.Token);
- _timeShiftSyncTask.Start();
- //_timeShiftSyncThread = new Thread(SyncTimestampDisplayWorker);
- //_timeShiftSyncThread.IsBackground = true;
- //_timeShiftSyncThread.Start();
+ splitContainerLogWindow.Panel2Collapsed = true;
+ advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE;
- _logEventHandlerTask = new Task(LogEventWorker, cts.Token);
- _logEventHandlerTask.Start();
- //_logEventHandlerThread = new Thread(LogEventWorker);
- //_logEventHandlerThread.IsBackground = true;
- //_logEventHandlerThread.Start();
+ _timeShiftSyncTask = new Task(SyncTimestampDisplayWorker, cts.Token);
+ _timeShiftSyncTask.Start();
+ //_timeShiftSyncThread = new Thread(SyncTimestampDisplayWorker);
+ //_timeShiftSyncThread.IsBackground = true;
+ //_timeShiftSyncThread.Start();
- //this.filterUpdateThread = new Thread(new ThreadStart(this.FilterUpdateWorker));
- //this.filterUpdateThread.Start();
+ _logEventHandlerTask = new Task(LogEventWorker, cts.Token);
+ _logEventHandlerTask.Start();
+ //_logEventHandlerThread = new Thread(LogEventWorker);
+ //_logEventHandlerThread.IsBackground = true;
+ //_logEventHandlerThread.Start();
- _advancedButtonImage = advancedButton.Image;
- _searchButtonImage = filterSearchButton.Image;
- filterSearchButton.Image = null;
+ //this.filterUpdateThread = new Thread(new ThreadStart(this.FilterUpdateWorker));
+ //this.filterUpdateThread.Start();
- dataGridView.EditModeMenuStrip = editModeContextMenuStrip;
- markEditModeToolStripMenuItem.Enabled = true;
+ _advancedButtonImage = advancedButton.Image;
+ _searchButtonImage = filterSearchButton.Image;
+ filterSearchButton.Image = null;
- _panelOpenButtonImage = Resources.Resources.Arrow_menu_open;
- _panelCloseButtonImage = Resources.Resources.Arrow_menu_close;
+ dataGridView.EditModeMenuStrip = editModeContextMenuStrip;
+ markEditModeToolStripMenuItem.Enabled = true;
- Settings settings = configManager.Settings;
+ _panelOpenButtonImage = Resources.Resources.Arrow_menu_open;
+ _panelCloseButtonImage = Resources.Resources.Arrow_menu_close;
- if (settings.appBounds.Right > 0)
- {
- Bounds = settings.appBounds;
- }
+ Settings settings = configManager.Settings;
- _waitingForClose = false;
- dataGridView.Enabled = false;
- dataGridView.ColumnDividerDoubleClick += OnDataGridViewColumnDividerDoubleClick;
- ShowAdvancedFilterPanel(false);
- filterKnobBackSpread.MinValue = 0;
- filterKnobBackSpread.MaxValue = SPREAD_MAX;
- filterKnobBackSpread.ValueChanged += OnFilterKnobControlValueChanged;
- filterKnobForeSpread.MinValue = 0;
- filterKnobForeSpread.MaxValue = SPREAD_MAX;
- filterKnobForeSpread.ValueChanged += OnFilterKnobControlValueChanged;
- fuzzyKnobControl.MinValue = 0;
- fuzzyKnobControl.MaxValue = 10;
- //PreferencesChanged(settings.preferences, true);
- AdjustHighlightSplitterWidth();
- ToggleHighlightPanel(false); // hidden
-
- _bookmarkProvider.BookmarkAdded += OnBookmarkProviderBookmarkAdded;
- _bookmarkProvider.BookmarkRemoved += OnBookmarkProviderBookmarkRemoved;
- _bookmarkProvider.AllBookmarksRemoved += OnBookmarkProviderAllBookmarksRemoved;
-
- ResumeLayout();
-
- ChangeTheme(Controls);
+ if (settings.appBounds.Right > 0)
+ {
+ Bounds = settings.appBounds;
}
-
+ _waitingForClose = false;
+ dataGridView.Enabled = false;
+ dataGridView.ColumnDividerDoubleClick += OnDataGridViewColumnDividerDoubleClick;
+ ShowAdvancedFilterPanel(false);
+ filterKnobBackSpread.MinValue = 0;
+ filterKnobBackSpread.MaxValue = SPREAD_MAX;
+ filterKnobBackSpread.ValueChanged += OnFilterKnobControlValueChanged;
+ filterKnobForeSpread.MinValue = 0;
+ filterKnobForeSpread.MaxValue = SPREAD_MAX;
+ filterKnobForeSpread.ValueChanged += OnFilterKnobControlValueChanged;
+ fuzzyKnobControl.MinValue = 0;
+ fuzzyKnobControl.MaxValue = 10;
+ //PreferencesChanged(settings.preferences, true);
+ AdjustHighlightSplitterWidth();
+ ToggleHighlightPanel(false); // hidden
+
+ _bookmarkProvider.BookmarkAdded += OnBookmarkProviderBookmarkAdded;
+ _bookmarkProvider.BookmarkRemoved += OnBookmarkProviderBookmarkRemoved;
+ _bookmarkProvider.AllBookmarksRemoved += OnBookmarkProviderAllBookmarksRemoved;
+
+ ResumeLayout();
+
+ ChangeTheme(Controls);
+ }
- #endregion
- #region ColorTheme
- public void ChangeTheme(Control.ControlCollection container)
+
+ #endregion
+
+ #region ColorTheme
+ public void ChangeTheme (Control.ControlCollection container)
+ {
+ #region ApplyColorToAllControls
+ foreach (Control component in container)
{
- #region ApplyColorToAllControls
- foreach (Control component in container)
+ if (component.Controls != null && component.Controls.Count > 0)
{
- if (component.Controls != null && component.Controls.Count > 0)
- {
- ChangeTheme(component.Controls);
- component.BackColor = ColorMode.BackgroundColor;
- component.ForeColor = ColorMode.ForeColor;
- }
- else
- {
- component.BackColor = ColorMode.BackgroundColor;
- component.ForeColor = ColorMode.ForeColor;
- }
-
+ ChangeTheme(component.Controls);
+ component.BackColor = ColorMode.BackgroundColor;
+ component.ForeColor = ColorMode.ForeColor;
}
- #endregion
-
- #region DataGridView
-
- // Main DataGridView
- dataGridView.BackgroundColor = ColorMode.DockBackgroundColor;
- dataGridView.ColumnHeadersDefaultCellStyle.BackColor = ColorMode.BackgroundColor;
- dataGridView.ColumnHeadersDefaultCellStyle.ForeColor = ColorMode.ForeColor;
- dataGridView.EnableHeadersVisualStyles = false;
-
- // Filter dataGridView
- filterGridView.BackgroundColor = ColorMode.DockBackgroundColor;
- filterGridView.ColumnHeadersDefaultCellStyle.BackColor = ColorMode.BackgroundColor;
- filterGridView.ColumnHeadersDefaultCellStyle.ForeColor = ColorMode.ForeColor;
- filterGridView.EnableHeadersVisualStyles = false;
-
- // Colors for menu
- dataGridContextMenuStrip.Renderer = new ExtendedMenuStripRenderer();
- bookmarkContextMenuStrip.Renderer = new ExtendedMenuStripRenderer();
- columnContextMenuStrip.Renderer = new ExtendedMenuStripRenderer();
- editModeContextMenuStrip.Renderer = new ExtendedMenuStripRenderer();
- filterContextMenuStrip.Renderer = new ExtendedMenuStripRenderer();
- filterListContextMenuStrip.Renderer = new ExtendedMenuStripRenderer();
-
- foreach (ToolStripItem item in dataGridContextMenuStrip.Items)
+ else
{
- item.ForeColor = ColorMode.ForeColor;
- item.BackColor = ColorMode.MenuBackgroundColor;
+ component.BackColor = ColorMode.BackgroundColor;
+ component.ForeColor = ColorMode.ForeColor;
}
- foreach (ToolStripItem item in bookmarkContextMenuStrip.Items)
- {
- item.ForeColor = ColorMode.ForeColor;
- item.BackColor = ColorMode.MenuBackgroundColor;
- }
+ }
+ #endregion
- foreach (ToolStripItem item in columnContextMenuStrip.Items)
- {
- item.ForeColor = ColorMode.ForeColor;
- item.BackColor = ColorMode.MenuBackgroundColor;
- }
+ #region DataGridView
+
+ // Main DataGridView
+ dataGridView.BackgroundColor = ColorMode.DockBackgroundColor;
+ dataGridView.ColumnHeadersDefaultCellStyle.BackColor = ColorMode.BackgroundColor;
+ dataGridView.ColumnHeadersDefaultCellStyle.ForeColor = ColorMode.ForeColor;
+ dataGridView.EnableHeadersVisualStyles = false;
+
+ // Filter dataGridView
+ filterGridView.BackgroundColor = ColorMode.DockBackgroundColor;
+ filterGridView.ColumnHeadersDefaultCellStyle.BackColor = ColorMode.BackgroundColor;
+ filterGridView.ColumnHeadersDefaultCellStyle.ForeColor = ColorMode.ForeColor;
+ filterGridView.EnableHeadersVisualStyles = false;
+
+ // Colors for menu
+ dataGridContextMenuStrip.Renderer = new ExtendedMenuStripRenderer();
+ bookmarkContextMenuStrip.Renderer = new ExtendedMenuStripRenderer();
+ columnContextMenuStrip.Renderer = new ExtendedMenuStripRenderer();
+ editModeContextMenuStrip.Renderer = new ExtendedMenuStripRenderer();
+ filterContextMenuStrip.Renderer = new ExtendedMenuStripRenderer();
+ filterListContextMenuStrip.Renderer = new ExtendedMenuStripRenderer();
+
+ foreach (ToolStripItem item in dataGridContextMenuStrip.Items)
+ {
+ item.ForeColor = ColorMode.ForeColor;
+ item.BackColor = ColorMode.MenuBackgroundColor;
+ }
- foreach (ToolStripItem item in editModeContextMenuStrip.Items)
- {
- item.ForeColor = ColorMode.ForeColor;
- item.BackColor = ColorMode.MenuBackgroundColor;
- }
+ foreach (ToolStripItem item in bookmarkContextMenuStrip.Items)
+ {
+ item.ForeColor = ColorMode.ForeColor;
+ item.BackColor = ColorMode.MenuBackgroundColor;
+ }
- foreach (ToolStripItem item in filterContextMenuStrip.Items)
- {
- item.ForeColor = ColorMode.ForeColor;
- item.BackColor = ColorMode.MenuBackgroundColor;
- }
+ foreach (ToolStripItem item in columnContextMenuStrip.Items)
+ {
+ item.ForeColor = ColorMode.ForeColor;
+ item.BackColor = ColorMode.MenuBackgroundColor;
+ }
- foreach (ToolStripItem item in filterListContextMenuStrip.Items)
- {
- item.ForeColor = ColorMode.ForeColor;
- item.BackColor = ColorMode.MenuBackgroundColor;
- }
+ foreach (ToolStripItem item in editModeContextMenuStrip.Items)
+ {
+ item.ForeColor = ColorMode.ForeColor;
+ item.BackColor = ColorMode.MenuBackgroundColor;
+ }
- // Colors for menu
- filterContextMenuStrip.Renderer = new ExtendedMenuStripRenderer();
+ foreach (ToolStripItem item in filterContextMenuStrip.Items)
+ {
+ item.ForeColor = ColorMode.ForeColor;
+ item.BackColor = ColorMode.MenuBackgroundColor;
+ }
- for (var y = 0; y < filterContextMenuStrip.Items.Count; y++)
- {
- var item = filterContextMenuStrip.Items[y];
- item.ForeColor = ColorMode.ForeColor;
- item.BackColor = ColorMode.MenuBackgroundColor;
- }
+ foreach (ToolStripItem item in filterListContextMenuStrip.Items)
+ {
+ item.ForeColor = ColorMode.ForeColor;
+ item.BackColor = ColorMode.MenuBackgroundColor;
+ }
- #endregion DataGridView
+ // Colors for menu
+ filterContextMenuStrip.Renderer = new ExtendedMenuStripRenderer();
- filterComboBox.BackColor = ColorMode.DockBackgroundColor;
+ for (var y = 0; y < filterContextMenuStrip.Items.Count; y++)
+ {
+ var item = filterContextMenuStrip.Items[y];
+ item.ForeColor = ColorMode.ForeColor;
+ item.BackColor = ColorMode.MenuBackgroundColor;
}
- #endregion
+ #endregion DataGridView
- #region Delegates
+ filterComboBox.BackColor = ColorMode.DockBackgroundColor;
+ }
- public delegate void BookmarkAddedEventHandler(object sender, EventArgs e);
+ #endregion
- public delegate void BookmarkRemovedEventHandler(object sender, EventArgs e);
+ #region Delegates
- public delegate void BookmarkTextChangedEventHandler(object sender, BookmarkEventArgs e);
+ public delegate void BookmarkAddedEventHandler (object sender, EventArgs e);
- public delegate void ColumnizerChangedEventHandler(object sender, ColumnizerEventArgs e);
+ public delegate void BookmarkRemovedEventHandler (object sender, EventArgs e);
- public delegate void CurrentHighlightGroupChangedEventHandler(object sender, CurrentHighlightGroupChangedEventArgs e);
+ public delegate void BookmarkTextChangedEventHandler (object sender, BookmarkEventArgs e);
- public delegate void FileNotFoundEventHandler(object sender, EventArgs e);
+ public delegate void ColumnizerChangedEventHandler (object sender, ColumnizerEventArgs e);
- public delegate void FileRespawnedEventHandler(object sender, EventArgs e);
+ public delegate void CurrentHighlightGroupChangedEventHandler (object sender, CurrentHighlightGroupChangedEventArgs e);
- public delegate void FilterListChangedEventHandler(object sender, FilterListChangedEventArgs e);
+ public delegate void FileNotFoundEventHandler (object sender, EventArgs e);
- // used for filterTab restore
- public delegate void FilterRestoreFx(LogWindow newWin, PersistenceData persistenceData);
+ public delegate void FileRespawnedEventHandler (object sender, EventArgs e);
- public delegate void GuiStateEventHandler(object sender, GuiStateArgs e);
+ public delegate void FilterListChangedEventHandler (object sender, FilterListChangedEventArgs e);
- public delegate void ProgressBarEventHandler(object sender, ProgressEventArgs e);
+ // used for filterTab restore
+ public delegate void FilterRestoreFx (LogWindow newWin, PersistenceData persistenceData);
- public delegate void RestoreFiltersFx(PersistenceData persistenceData);
+ public delegate void GuiStateEventHandler (object sender, GuiStateArgs e);
- public delegate bool ScrollToTimestampFx(DateTime timestamp, bool roundToSeconds, bool triggerSyncCall);
+ public delegate void ProgressBarEventHandler (object sender, ProgressEventArgs e);
- public delegate void StatusLineEventHandler(object sender, StatusLineEventArgs e);
+ public delegate void RestoreFiltersFx (PersistenceData persistenceData);
- public delegate void SyncModeChangedEventHandler(object sender, SyncModeEventArgs e);
+ public delegate bool ScrollToTimestampFx (DateTime timestamp, bool roundToSeconds, bool triggerSyncCall);
- public delegate void TailFollowedEventHandler(object sender, EventArgs e);
+ public delegate void StatusLineEventHandler (object sender, StatusLineEventArgs e);
- #endregion
+ public delegate void SyncModeChangedEventHandler (object sender, SyncModeEventArgs e);
- #region Events
+ public delegate void TailFollowedEventHandler (object sender, EventArgs e);
- public event FileSizeChangedEventHandler FileSizeChanged;
+ #endregion
- public event ProgressBarEventHandler ProgressBarUpdate;
+ #region Events
- public event StatusLineEventHandler StatusLineEvent;
+ public event FileSizeChangedEventHandler FileSizeChanged;
- public event GuiStateEventHandler GuiStateUpdate;
+ public event ProgressBarEventHandler ProgressBarUpdate;
- public event TailFollowedEventHandler TailFollowed;
+ public event StatusLineEventHandler StatusLineEvent;
- public event FileNotFoundEventHandler FileNotFound;
+ public event GuiStateEventHandler GuiStateUpdate;
- public event FileRespawnedEventHandler FileRespawned;
+ public event TailFollowedEventHandler TailFollowed;
- public event FilterListChangedEventHandler FilterListChanged;
+ public event FileNotFoundEventHandler FileNotFound;
- public event CurrentHighlightGroupChangedEventHandler CurrentHighlightGroupChanged;
+ public event FileRespawnedEventHandler FileRespawned;
- public event BookmarkAddedEventHandler BookmarkAdded;
+ public event FilterListChangedEventHandler FilterListChanged;
- public event BookmarkRemovedEventHandler BookmarkRemoved;
+ public event CurrentHighlightGroupChangedEventHandler CurrentHighlightGroupChanged;
- public event BookmarkTextChangedEventHandler BookmarkTextChanged;
+ public event BookmarkAddedEventHandler BookmarkAdded;
- public event ColumnizerChangedEventHandler ColumnizerChanged;
+ public event BookmarkRemovedEventHandler BookmarkRemoved;
- public event SyncModeChangedEventHandler SyncModeChanged;
+ public event BookmarkTextChangedEventHandler BookmarkTextChanged;
- #endregion
+ public event ColumnizerChangedEventHandler ColumnizerChanged;
- #region Properties
+ public event SyncModeChangedEventHandler SyncModeChanged;
- public Color BookmarkColor { get; set; } = Color.FromArgb(165, 200, 225);
+ #endregion
- public ILogLineColumnizer CurrentColumnizer
+ #region Properties
+
+ public Color BookmarkColor { get; set; } = Color.FromArgb(165, 200, 225);
+
+ public ILogLineColumnizer CurrentColumnizer
+ {
+ get => _currentColumnizer;
+ private set
{
- get => _currentColumnizer;
- private set
+ lock (_currentColumnizerLock)
{
- lock (_currentColumnizerLock)
- {
- _currentColumnizer = value;
- _logger.Debug($"Setting columnizer {_currentColumnizer.GetName()} ");
- }
+ _currentColumnizer = value;
+ _logger.Debug($"Setting columnizer {_currentColumnizer.GetName()} ");
}
}
+ }
- public bool ShowBookmarkBubbles
+ public bool ShowBookmarkBubbles
+ {
+ get => _guiStateArgs.ShowBookmarkBubbles;
+ set
{
- get => _guiStateArgs.ShowBookmarkBubbles;
- set
- {
- _guiStateArgs.ShowBookmarkBubbles = dataGridView.PaintWithOverlays = value;
- dataGridView.Refresh();
- }
+ _guiStateArgs.ShowBookmarkBubbles = dataGridView.PaintWithOverlays = value;
+ dataGridView.Refresh();
}
+ }
- public string FileName { get; private set; }
+ public string FileName { get; private set; }
- public string SessionFileName { get; set; } = null;
+ public string SessionFileName { get; set; } = null;
- public bool IsMultiFile
- {
- get => _isMultiFile;
- private set => _guiStateArgs.IsMultiFileActive = _isMultiFile = value;
- }
+ public bool IsMultiFile
+ {
+ get => _isMultiFile;
+ private set => _guiStateArgs.IsMultiFileActive = _isMultiFile = value;
+ }
- public bool IsTempFile { get; }
+ public bool IsTempFile { get; }
- private readonly IConfigManager ConfigManager;
+ private readonly IConfigManager ConfigManager;
- public string TempTitleName { get; set; } = "";
+ public string TempTitleName { get; set; } = "";
- internal FilterPipe FilterPipe { get; set; } = null;
+ internal FilterPipe FilterPipe { get; set; } = null;
- public string Title
+ public string Title
+ {
+ get
{
- get
+ if (IsTempFile)
{
- if (IsTempFile)
- {
- return TempTitleName;
- }
-
- return FileName;
+ return TempTitleName;
}
+
+ return FileName;
}
+ }
- public ColumnizerCallback ColumnizerCallbackObject { get; }
+ public ColumnizerCallback ColumnizerCallbackObject { get; }
- public bool ForcePersistenceLoading { get; set; }
+ public bool ForcePersistenceLoading { get; set; }
- public string ForcedPersistenceFileName { get; set; } = null;
+ public string ForcedPersistenceFileName { get; set; } = null;
- public Preferences Preferences => ConfigManager.Settings.Preferences;
+ public Preferences Preferences => ConfigManager.Settings.Preferences;
- public string GivenFileName { get; set; } = null;
+ public string GivenFileName { get; set; } = null;
- public TimeSyncList TimeSyncList { get; private set; }
+ public TimeSyncList TimeSyncList { get; private set; }
- public bool IsTimeSynced => TimeSyncList != null;
+ public bool IsTimeSynced => TimeSyncList != null;
- protected EncodingOptions EncodingOptions { get; set; }
+ protected EncodingOptions EncodingOptions { get; set; }
- public IBookmarkData BookmarkData => _bookmarkProvider;
+ public IBookmarkData BookmarkData => _bookmarkProvider;
- public Font MonospacedFont { get; private set; }
+ public Font MonospacedFont { get; private set; }
- public Font NormalFont { get; private set; }
+ public Font NormalFont { get; private set; }
- public Font BoldFont { get; private set; }
+ public Font BoldFont { get; private set; }
- LogfileReader ILogWindow._logFileReader => _logFileReader;
+ LogfileReader ILogWindow.LogFileReader => _logFileReader;
- event FileSizeChangedEventHandler ILogWindow.FileSizeChanged
+ event FileSizeChangedEventHandler ILogWindow.FileSizeChanged
+ {
+ add
{
- add
- {
- this.FileSizeChanged += new FileSizeChangedEventHandler(value);
- }
-
- remove
- {
- this.FileSizeChanged -= new FileSizeChangedEventHandler(value);
- }
+ this.FileSizeChanged += new FileSizeChangedEventHandler(value);
}
- event EventHandler ILogWindow.TailFollowed
+ remove
{
- add
- {
- this.TailFollowed += new TailFollowedEventHandler(value);
- }
-
- remove
- {
- this.TailFollowed -= new TailFollowedEventHandler(value);
- }
+ this.FileSizeChanged -= new FileSizeChangedEventHandler(value);
}
+ }
- #endregion
-
- #region Public methods
-
- public ILogLine GetLogLine(int lineNum)
+ event EventHandler ILogWindow.TailFollowed
+ {
+ add
{
- return _logFileReader.GetLogLine(lineNum);
+ this.TailFollowed += new TailFollowedEventHandler(value);
}
- public Bookmark GetBookmarkForLine(int lineNum)
+ remove
{
- return _bookmarkProvider.GetBookmarkForLine(lineNum);
+ this.TailFollowed -= new TailFollowedEventHandler(value);
}
+ }
- #endregion
+ #endregion
- #region Internals
+ #region Public methods
- internal IColumnizedLogLine GetColumnsForLine(int lineNumber)
- {
- return _columnCache.GetColumnsForLine(_logFileReader, lineNumber, CurrentColumnizer, ColumnizerCallbackObject);
-
- //string line = this.logFileReader.GetLogLine(lineNumber);
- //if (line != null)
- //{
- // string[] cols;
- // this.columnizerCallback.LineNum = lineNumber;
- // cols = this.CurrentColumnizer.SplitLine(this.columnizerCallback, line);
- // return cols;
- //}
- //else
- //{
- // return null;
- //}
- }
+ public ILogLine GetLogLine (int lineNum)
+ {
+ return _logFileReader.GetLogLine(lineNum);
+ }
- internal void RefreshAllGrids()
- {
- dataGridView.Refresh();
- filterGridView.Refresh();
- }
+ public Bookmark GetBookmarkForLine (int lineNum)
+ {
+ return _bookmarkProvider.GetBookmarkForLine(lineNum);
+ }
+
+ #endregion
+
+ #region Internals
+
+ internal IColumnizedLogLine GetColumnsForLine (int lineNumber)
+ {
+ return _columnCache.GetColumnsForLine(_logFileReader, lineNumber, CurrentColumnizer, ColumnizerCallbackObject);
+
+ //string line = this.logFileReader.GetLogLine(lineNumber);
+ //if (line != null)
+ //{
+ // string[] cols;
+ // this.columnizerCallback.LineNum = lineNumber;
+ // cols = this.CurrentColumnizer.SplitLine(this.columnizerCallback, line);
+ // return cols;
+ //}
+ //else
+ //{
+ // return null;
+ //}
+ }
+
+ internal void RefreshAllGrids ()
+ {
+ dataGridView.Refresh();
+ filterGridView.Refresh();
+ }
- internal void ChangeMultifileMask()
+ internal void ChangeMultifileMask ()
+ {
+ MultiFileMaskDialog dlg = new(this, FileName)
{
- MultiFileMaskDialog dlg = new(this, FileName)
- {
- Owner = this,
- MaxDays = _multiFileOptions.MaxDayTry,
- FileNamePattern = _multiFileOptions.FormatPattern
- };
+ Owner = this,
+ MaxDays = _multiFileOptions.MaxDayTry,
+ FileNamePattern = _multiFileOptions.FormatPattern
+ };
- if (dlg.ShowDialog() == DialogResult.OK)
+ if (dlg.ShowDialog() == DialogResult.OK)
+ {
+ _multiFileOptions.FormatPattern = dlg.FileNamePattern;
+ _multiFileOptions.MaxDayTry = dlg.MaxDays;
+ if (IsMultiFile)
{
- _multiFileOptions.FormatPattern = dlg.FileNamePattern;
- _multiFileOptions.MaxDayTry = dlg.MaxDays;
- if (IsMultiFile)
- {
- Reload();
- }
+ Reload();
}
}
+ }
- internal void ToggleColumnFinder(bool show, bool setFocus)
+ internal void ToggleColumnFinder (bool show, bool setFocus)
+ {
+ _guiStateArgs.ColumnFinderVisible = show;
+ if (show)
{
- _guiStateArgs.ColumnFinderVisible = show;
- if (show)
- {
- columnComboBox.AutoCompleteMode = AutoCompleteMode.Suggest;
- columnComboBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
- columnComboBox.AutoCompleteCustomSource = [.. CurrentColumnizer.GetColumnNames()];
- if (setFocus)
- {
- columnComboBox.Focus();
- }
- }
- else
+ columnComboBox.AutoCompleteMode = AutoCompleteMode.Suggest;
+ columnComboBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
+ columnComboBox.AutoCompleteCustomSource = [.. CurrentColumnizer.GetColumnNames()];
+ if (setFocus)
{
- dataGridView.Focus();
+ columnComboBox.Focus();
}
-
- tableLayoutPanel1.RowStyles[0].Height = show ? 28 : 0;
+ }
+ else
+ {
+ dataGridView.Focus();
}
- #endregion
+ tableLayoutPanel1.RowStyles[0].Height = show ? 28 : 0;
+ }
- #region Overrides
+ #endregion
- protected override string GetPersistString()
- {
- return "LogWindow#" + FileName;
- }
+ #region Overrides
- #endregion
+ protected override string GetPersistString ()
+ {
+ return "LogWindow#" + FileName;
+ }
+
+ #endregion
- private void OnButtonSizeChanged(object sender, EventArgs e)
+ private void OnButtonSizeChanged (object sender, EventArgs e)
+ {
+ if (sender is Button button && button.Image != null)
{
- if (sender is Button button && button.Image != null)
- {
- button.ImageAlign = ContentAlignment.MiddleCenter;
- button.Image = new Bitmap(button.Image, new Size(button.Size.Height, button.Size.Height));
- }
+ button.ImageAlign = ContentAlignment.MiddleCenter;
+ button.Image = new Bitmap(button.Image, new Size(button.Size.Height, button.Size.Height));
}
+ }
- // used for external wait fx WaitForLoadFinished()
+ // used for external wait fx WaitForLoadFinished()
- private delegate void SelectLineFx(int line, bool triggerSyncCall);
+ private delegate void SelectLineFx (int line, bool triggerSyncCall);
- private Action, List, List> FilterFxAction;
- //private delegate void FilterFx(FilterParams filterParams, List filterResultLines, List lastFilterResultLines, List filterHitList);
+ private Action, List, List> FilterFxAction;
+ //private delegate void FilterFx(FilterParams filterParams, List filterResultLines, List lastFilterResultLines, List filterHitList);
- private delegate void UpdateProgressBarFx(int lineNum);
+ private delegate void UpdateProgressBarFx (int lineNum);
- private delegate void SetColumnizerFx(ILogLineColumnizer columnizer);
+ private delegate void SetColumnizerFx (ILogLineColumnizer columnizer);
- private delegate void WriteFilterToTabFinishedFx(FilterPipe pipe, string namePrefix, PersistenceData persistenceData);
+ private delegate void WriteFilterToTabFinishedFx (FilterPipe pipe, string namePrefix, PersistenceData persistenceData);
- private delegate void SetBookmarkFx(int lineNum, string comment);
+ private delegate void SetBookmarkFx (int lineNum, string comment);
- private delegate void FunctionWith1BoolParam(bool arg);
+ private delegate void FunctionWith1BoolParam (bool arg);
- private delegate void PatternStatisticFx(PatternArgs patternArgs);
+ private delegate void PatternStatisticFx (PatternArgs patternArgs);
- private delegate void ActionPluginExecuteFx(string keyword, string param, ILogExpertCallback callback, ILogLineColumnizer columnizer);
+ private delegate void ActionPluginExecuteFx (string keyword, string param, ILogExpertCallback callback, ILogLineColumnizer columnizer);
- private delegate void PositionAfterReloadFx(ReloadMemento reloadMemento);
+ private delegate void PositionAfterReloadFx (ReloadMemento reloadMemento);
- private delegate void AutoResizeColumnsFx(BufferedDataGridView gridView);
+ private delegate void AutoResizeColumnsFx (BufferedDataGridView gridView);
- private delegate bool BoolReturnDelegate();
+ private delegate bool BoolReturnDelegate ();
- // =================== ILogLineColumnizerCallback ============================
+ // =================== ILogLineColumnizerCallback ============================
#if DEBUG
- internal void DumpBufferInfo()
- {
- int currentLineNum = dataGridView.CurrentCellAddress.Y;
- _logFileReader.LogBufferInfoForLine(currentLineNum);
- }
+ internal void DumpBufferInfo ()
+ {
+ int currentLineNum = dataGridView.CurrentCellAddress.Y;
+ _logFileReader.LogBufferInfoForLine(currentLineNum);
+ }
- internal void DumpBufferDiagnostic()
- {
- _logFileReader.LogBufferDiagnostic();
- }
+ internal void DumpBufferDiagnostic ()
+ {
+ _logFileReader.LogBufferDiagnostic();
+ }
- void ILogWindow.SelectLine(int lineNum, bool v1, bool v2)
- {
- SelectLine(lineNum, v1, v2);
- }
+ void ILogWindow.SelectLine (int lineNum, bool v1, bool v2)
+ {
+ SelectLine(lineNum, v1, v2);
+ }
- void ILogWindow.AddTempFileTab(string fileName, string title)
- {
- AddTempFileTab(fileName, title);
- }
+ void ILogWindow.AddTempFileTab (string fileName, string title)
+ {
+ AddTempFileTab(fileName, title);
+ }
- void ILogWindow.WritePipeTab(IList lineEntryList, string title)
- {
- WritePipeTab(lineEntryList, title);
- }
-#endif
+ void ILogWindow.WritePipeTab (IList lineEntryList, string title)
+ {
+ WritePipeTab(lineEntryList, title);
}
+#endif
}
\ No newline at end of file
diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs
index 5a4f2034..a61a0669 100644
--- a/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs
+++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs
@@ -1,4 +1,6 @@
-using LogExpert.Classes.Filter;
+using System.ComponentModel;
+
+using LogExpert.Classes.Filter;
using LogExpert.Core.Classes;
using LogExpert.Core.Classes.Filter;
using LogExpert.Core.Classes.Highlight;
@@ -10,80 +12,79 @@
using LogExpert.UI.Dialogs;
using LogExpert.UI.Entities;
using LogExpert.UI.Extensions;
-using System.ComponentModel;
namespace LogExpert.UI.Controls.LogWindow
{
partial class LogWindow
{
- private void AutoResizeFilterBox()
+ private void AutoResizeFilterBox ()
{
filterSplitContainer.SplitterDistance = filterComboBox.Left + filterComboBox.GetMaxTextWidth();
}
#region Events handler
- protected void OnProgressBarUpdate(ProgressEventArgs e)
+ protected void OnProgressBarUpdate (ProgressEventArgs e)
{
ProgressBarUpdate?.Invoke(this, e);
}
- protected void OnStatusLine(StatusLineEventArgs e)
+ protected void OnStatusLine (StatusLineEventArgs e)
{
StatusLineEvent?.Invoke(this, e);
}
- protected void OnGuiState(GuiStateArgs e)
+ protected void OnGuiState (GuiStateArgs e)
{
GuiStateUpdate?.Invoke(this, e);
}
- protected void OnTailFollowed(EventArgs e)
+ protected void OnTailFollowed (EventArgs e)
{
TailFollowed?.Invoke(this, e);
}
- protected void OnFileNotFound(EventArgs e)
+ protected void OnFileNotFound (EventArgs e)
{
FileNotFound?.Invoke(this, e);
}
- protected void OnFileRespawned(EventArgs e)
+ protected void OnFileRespawned (EventArgs e)
{
FileRespawned?.Invoke(this, e);
}
- protected void OnFilterListChanged(LogWindow source)
+ protected void OnFilterListChanged (LogWindow source)
{
FilterListChanged?.Invoke(this, new FilterListChangedEventArgs(source));
}
- protected void OnCurrentHighlightListChanged()
+ protected void OnCurrentHighlightListChanged ()
{
CurrentHighlightGroupChanged?.Invoke(this, new CurrentHighlightGroupChangedEventArgs(this, _currentHighlightGroup));
}
- protected void OnBookmarkAdded()
+ protected void OnBookmarkAdded ()
{
BookmarkAdded?.Invoke(this, EventArgs.Empty);
}
- protected void OnBookmarkRemoved()
+ protected void OnBookmarkRemoved ()
{
BookmarkRemoved?.Invoke(this, EventArgs.Empty);
}
- protected void OnBookmarkTextChanged(Bookmark bookmark)
+ protected void OnBookmarkTextChanged (Bookmark bookmark)
{
BookmarkTextChanged?.Invoke(this, new BookmarkEventArgs(bookmark));
}
- protected void OnColumnizerChanged(ILogLineColumnizer columnizer)
+ protected void OnColumnizerChanged (ILogLineColumnizer columnizer)
{
ColumnizerChanged?.Invoke(this, new ColumnizerEventArgs(columnizer));
}
- protected void OnRegisterCancelHandler(IBackgroundProcessCancelHandler handler)
+ protected void OnRegisterCancelHandler (IBackgroundProcessCancelHandler handler)
{
lock (_cancelHandlerList)
{
@@ -91,7 +92,7 @@ protected void OnRegisterCancelHandler(IBackgroundProcessCancelHandler handler)
}
}
- protected void OnDeRegisterCancelHandler(IBackgroundProcessCancelHandler handler)
+ protected void OnDeRegisterCancelHandler (IBackgroundProcessCancelHandler handler)
{
lock (_cancelHandlerList)
{
@@ -99,12 +100,12 @@ protected void OnDeRegisterCancelHandler(IBackgroundProcessCancelHandler handler
}
}
- private void OnLogWindowLoad(object sender, EventArgs e)
+ private void OnLogWindowLoad (object sender, EventArgs e)
{
PreferencesChanged(_parentLogTabWin.Preferences, true, SettingsFlags.GuiOrColors);
}
- private void OnLogWindowDisposed(object sender, EventArgs e)
+ private void OnLogWindowDisposed (object sender, EventArgs e)
{
_waitingForClose = true;
_parentLogTabWin.HighlightSettingsChanged -= OnParentHighlightSettingsChanged;
@@ -113,12 +114,12 @@ private void OnLogWindowDisposed(object sender, EventArgs e)
FreeFromTimeSync();
}
- private void OnLogFileReaderLoadingStarted(object sender, LoadFileEventArgs e)
+ private void OnLogFileReaderLoadingStarted (object sender, LoadFileEventArgs e)
{
Invoke(LoadingStarted, e);
}
- private void OnLogFileReaderFinishedLoading(object sender, EventArgs e)
+ private void OnLogFileReaderFinishedLoading (object sender, EventArgs e)
{
//Thread.CurrentThread.Name = "FinishedLoading event thread";
_logger.Info("Finished loading.");
@@ -150,7 +151,7 @@ private void OnLogFileReaderFinishedLoading(object sender, EventArgs e)
_reloadMemento = null;
}
- private void OnLogFileReaderFileNotFound(object sender, EventArgs e)
+ private void OnLogFileReaderFileNotFound (object sender, EventArgs e)
{
if (!IsDisposed && !Disposing)
{
@@ -160,12 +161,12 @@ private void OnLogFileReaderFileNotFound(object sender, EventArgs e)
}
}
- private void OnLogFileReaderRespawned(object sender, EventArgs e)
+ private void OnLogFileReaderRespawned (object sender, EventArgs e)
{
BeginInvoke(new MethodInvoker(LogfileRespawned));
}
- private void OnLogWindowClosing(object sender, CancelEventArgs e)
+ private void OnLogWindowClosing (object sender, CancelEventArgs e)
{
if (Preferences.askForClose)
{
@@ -180,7 +181,7 @@ private void OnLogWindowClosing(object sender, CancelEventArgs e)
CloseLogWindow();
}
- private void OnDataGridViewColumnDividerDoubleClick(object sender, DataGridViewColumnDividerDoubleClickEventArgs e)
+ private void OnDataGridViewColumnDividerDoubleClick (object sender, DataGridViewColumnDividerDoubleClickEventArgs e)
{
e.Handled = true;
AutoResizeColumns(dataGridView);
@@ -189,7 +190,7 @@ private void OnDataGridViewColumnDividerDoubleClick(object sender, DataGridViewC
/**
* Event handler for the Load event from LogfileReader
*/
- private void OnLogFileReaderLoadFile(object sender, LoadFileEventArgs e)
+ private void OnLogFileReaderLoadFile (object sender, LoadFileEventArgs e)
{
if (e.NewFile)
{
@@ -211,7 +212,7 @@ private void OnLogFileReaderLoadFile(object sender, LoadFileEventArgs e)
}
}
- private void OnFileSizeChanged(object sender, LogEventArgs e)
+ private void OnFileSizeChanged (object sender, LogEventArgs e)
{
//OnFileSizeChanged(e); // now done in UpdateGrid()
_logger.Info("Got FileSizeChanged event. prevLines:{0}, curr lines: {1}", e.PrevLineCount, e.LineCount);
@@ -232,9 +233,9 @@ private void OnFileSizeChanged(object sender, LogEventArgs e)
}
}
- private void OnDataGridViewCellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
+ private void OnDataGridViewCellValueNeeded (object sender, DataGridViewCellValueEventArgs e)
{
- int startCount = CurrentColumnizer?.GetColumnCount() ?? 0;
+ var startCount = CurrentColumnizer?.GetColumnCount() ?? 0;
e.Value = GetCellValue(e.RowIndex, e.ColumnIndex);
@@ -243,7 +244,7 @@ private void OnDataGridViewCellValueNeeded(object sender, DataGridViewCellValueE
// TODO: Support reload all columns?
if (CurrentColumnizer != null && CurrentColumnizer.GetColumnCount() > startCount)
{
- for (int i = startCount; i < CurrentColumnizer.GetColumnCount(); i++)
+ for (var i = startCount; i < CurrentColumnizer.GetColumnCount(); i++)
{
var colName = CurrentColumnizer.GetColumnNames()[i];
dataGridView.Columns.Add(PaintHelper.CreateTitleColumn(colName));
@@ -251,7 +252,7 @@ private void OnDataGridViewCellValueNeeded(object sender, DataGridViewCellValueE
}
}
- private void OnDataGridViewCellValuePushed(object sender, DataGridViewCellValueEventArgs e)
+ private void OnDataGridViewCellValuePushed (object sender, DataGridViewCellValueEventArgs e)
{
if (!CurrentColumnizer.IsTimeshiftImplemented())
{
@@ -259,9 +260,9 @@ private void OnDataGridViewCellValuePushed(object sender, DataGridViewCellValueE
}
ILogLine line = _logFileReader.GetLogLine(e.RowIndex);
- int offset = CurrentColumnizer.GetTimeOffset();
+ var offset = CurrentColumnizer.GetTimeOffset();
CurrentColumnizer.SetTimeOffset(0);
- ColumnizerCallbackObject.LineNum = e.RowIndex;
+ ColumnizerCallbackObject.SetLineNum(e.RowIndex);
IColumnizedLogLine cols = CurrentColumnizer.SplitLine(ColumnizerCallbackObject, line);
CurrentColumnizer.SetTimeOffset(offset);
if (cols.ColumnValues.Length <= e.ColumnIndex - 2)
@@ -269,14 +270,14 @@ private void OnDataGridViewCellValuePushed(object sender, DataGridViewCellValueE
return;
}
- string oldValue = cols.ColumnValues[e.ColumnIndex - 2].FullValue;
- string newValue = (string)e.Value;
+ var oldValue = cols.ColumnValues[e.ColumnIndex - 2].FullValue;
+ var newValue = (string)e.Value;
//string oldValue = (string) this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
CurrentColumnizer.PushValue(ColumnizerCallbackObject, e.ColumnIndex - 2, newValue, oldValue);
dataGridView.Refresh();
TimeSpan timeSpan = new(CurrentColumnizer.GetTimeOffset() * TimeSpan.TicksPerMillisecond);
- string span = timeSpan.ToString();
- int index = span.LastIndexOf('.');
+ var span = timeSpan.ToString();
+ var index = span.LastIndexOf('.');
if (index > 0)
{
span = span.Substring(0, index + 4);
@@ -286,12 +287,12 @@ private void OnDataGridViewCellValuePushed(object sender, DataGridViewCellValueE
SendGuiStateUpdate();
}
- private void OnDataGridViewRowHeightInfoNeeded(object sender, DataGridViewRowHeightInfoNeededEventArgs e)
+ private void OnDataGridViewRowHeightInfoNeeded (object sender, DataGridViewRowHeightInfoNeededEventArgs e)
{
e.Height = GetRowHeight(e.RowIndex);
}
- private void OnDataGridViewCurrentCellChanged(object sender, EventArgs e)
+ private void OnDataGridViewCurrentCellChanged (object sender, EventArgs e)
{
if (dataGridView.CurrentRow != null)
{
@@ -312,32 +313,32 @@ private void OnDataGridViewCurrentCellChanged(object sender, EventArgs e)
}
}
- private void OnDataGridViewCellEndEdit(object sender, DataGridViewCellEventArgs e)
+ private void OnDataGridViewCellEndEdit (object sender, DataGridViewCellEventArgs e)
{
StatusLineText(string.Empty);
}
- private void OnEditControlKeyUp(object sender, KeyEventArgs e)
+ private void OnEditControlKeyUp (object sender, KeyEventArgs e)
{
UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender);
}
- private void OnEditControlKeyPress(object sender, KeyPressEventArgs e)
+ private void OnEditControlKeyPress (object sender, KeyPressEventArgs e)
{
UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender);
}
- private void OnEditControlClick(object sender, EventArgs e)
+ private void OnEditControlClick (object sender, EventArgs e)
{
UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender);
}
- private void OnEditControlKeyDown(object sender, KeyEventArgs e)
+ private void OnEditControlKeyDown (object sender, KeyEventArgs e)
{
UpdateEditColumnDisplay((DataGridViewTextBoxEditingControl)sender);
}
- private void OnDataGridViewPaint(object sender, PaintEventArgs e)
+ private void OnDataGridViewPaint (object sender, PaintEventArgs e)
{
if (ShowBookmarkBubbles)
{
@@ -349,14 +350,14 @@ private void OnDataGridViewPaint(object sender, PaintEventArgs e)
// Filter Grid stuff
// ======================================================================================
- private void OnFilterSearchButtonClick(object sender, EventArgs e)
+ private void OnFilterSearchButtonClick (object sender, EventArgs e)
{
FilterSearch();
}
- private void OnFilterGridViewCellPainting(object sender, DataGridViewCellPaintingEventArgs e)
+ private void OnFilterGridViewCellPainting (object sender, DataGridViewCellPaintingEventArgs e)
{
- BufferedDataGridView gridView = (BufferedDataGridView)sender;
+ var gridView = (BufferedDataGridView)sender;
if (e.RowIndex < 0 || e.ColumnIndex < 0 || _filterResultList.Count <= e.RowIndex)
{
@@ -364,7 +365,7 @@ private void OnFilterGridViewCellPainting(object sender, DataGridViewCellPaintin
return;
}
- int lineNum = _filterResultList[e.RowIndex];
+ var lineNum = _filterResultList[e.RowIndex];
ILogLine line = _logFileReader.GetLogLineWithWait(lineNum).Result;
if (line != null)
@@ -380,7 +381,7 @@ private void OnFilterGridViewCellPainting(object sender, DataGridViewCellPaintin
}
else
{
- Color color = Color.FromArgb(255, 170, 170, 170);
+ var color = Color.FromArgb(255, 170, 170, 170);
brush = new SolidBrush(color);
}
@@ -458,7 +459,7 @@ private void OnFilterGridViewCellPainting(object sender, DataGridViewCellPaintin
}
}
- private void OnFilterGridViewCellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
+ private void OnFilterGridViewCellValueNeeded (object sender, DataGridViewCellValueEventArgs e)
{
if (e.RowIndex < 0 || e.ColumnIndex < 0 || _filterResultList.Count <= e.RowIndex)
{
@@ -466,16 +467,16 @@ private void OnFilterGridViewCellValueNeeded(object sender, DataGridViewCellValu
return;
}
- int lineNum = _filterResultList[e.RowIndex];
+ var lineNum = _filterResultList[e.RowIndex];
e.Value = GetCellValue(lineNum, e.ColumnIndex);
}
- private void OnFilterGridViewRowHeightInfoNeeded(object sender, DataGridViewRowHeightInfoNeededEventArgs e)
+ private void OnFilterGridViewRowHeightInfoNeeded (object sender, DataGridViewRowHeightInfoNeededEventArgs e)
{
e.Height = _lineHeight;
}
- private void OnFilterComboBoxKeyDown(object sender, KeyEventArgs e)
+ private void OnFilterComboBoxKeyDown (object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
@@ -483,7 +484,7 @@ private void OnFilterComboBoxKeyDown(object sender, KeyEventArgs e)
}
}
- private void OnFilterGridViewColumnDividerDoubleClick(object sender,
+ private void OnFilterGridViewColumnDividerDoubleClick (object sender,
DataGridViewColumnDividerDoubleClickEventArgs e)
{
e.Handled = true;
@@ -491,7 +492,7 @@ private void OnFilterGridViewColumnDividerDoubleClick(object sender,
BeginInvoke(fx, filterGridView);
}
- private void OnFilterGridViewCellDoubleClick(object sender, DataGridViewCellEventArgs e)
+ private void OnFilterGridViewCellDoubleClick (object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 0)
{
@@ -501,18 +502,18 @@ private void OnFilterGridViewCellDoubleClick(object sender, DataGridViewCellEven
if (filterGridView.CurrentRow != null && e.RowIndex >= 0)
{
- int lineNum = _filterResultList[filterGridView.CurrentRow.Index];
+ var lineNum = _filterResultList[filterGridView.CurrentRow.Index];
SelectAndEnsureVisible(lineNum, true);
}
}
- private void OnRangeCheckBoxCheckedChanged(object sender, EventArgs e)
+ private void OnRangeCheckBoxCheckedChanged (object sender, EventArgs e)
{
filterRangeComboBox.Enabled = rangeCheckBox.Checked;
CheckForFilterDirty();
}
- private void OnDataGridViewScroll(object sender, ScrollEventArgs e)
+ private void OnDataGridViewScroll (object sender, ScrollEventArgs e)
{
if (e.ScrollOrientation == ScrollOrientation.VerticalScroll)
{
@@ -539,7 +540,7 @@ private void OnDataGridViewScroll(object sender, ScrollEventArgs e)
}
}
- private void OnFilterGridViewKeyDown(object sender, KeyEventArgs e)
+ private void OnFilterGridViewKeyDown (object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
@@ -547,7 +548,7 @@ private void OnFilterGridViewKeyDown(object sender, KeyEventArgs e)
{
if (filterGridView.CurrentCellAddress.Y >= 0 && filterGridView.CurrentCellAddress.Y < _filterResultList.Count)
{
- int lineNum = _filterResultList[filterGridView.CurrentCellAddress.Y];
+ var lineNum = _filterResultList[filterGridView.CurrentCellAddress.Y];
SelectLine(lineNum, false, true);
e.Handled = true;
}
@@ -561,7 +562,7 @@ private void OnFilterGridViewKeyDown(object sender, KeyEventArgs e)
}
}
- private void OnDataGridViewKeyDown(object sender, KeyEventArgs e)
+ private void OnDataGridViewKeyDown (object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
@@ -583,7 +584,7 @@ private void OnDataGridViewKeyDown(object sender, KeyEventArgs e)
_shouldCallTimeSync = true;
}
- private void OnDataGridViewPreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
+ private void OnDataGridViewPreviewKeyDown (object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.Tab && e.Control)
{
@@ -591,7 +592,7 @@ private void OnDataGridViewPreviewKeyDown(object sender, PreviewKeyDownEventArgs
}
}
- private void OnDataGridViewCellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
+ private void OnDataGridViewCellContentDoubleClick (object sender, DataGridViewCellEventArgs e)
{
if (dataGridView.CurrentCell != null)
{
@@ -599,7 +600,7 @@ private void OnDataGridViewCellContentDoubleClick(object sender, DataGridViewCel
}
}
- private void OnSyncFilterCheckBoxCheckedChanged(object sender, EventArgs e)
+ private void OnSyncFilterCheckBoxCheckedChanged (object sender, EventArgs e)
{
if (syncFilterCheckBox.Checked)
{
@@ -607,27 +608,27 @@ private void OnSyncFilterCheckBoxCheckedChanged(object sender, EventArgs e)
}
}
- private void OnDataGridViewLeave(object sender, EventArgs e)
+ private void OnDataGridViewLeave (object sender, EventArgs e)
{
InvalidateCurrentRow(dataGridView);
}
- private void OnDataGridViewEnter(object sender, EventArgs e)
+ private void OnDataGridViewEnter (object sender, EventArgs e)
{
InvalidateCurrentRow(dataGridView);
}
- private void OnFilterGridViewEnter(object sender, EventArgs e)
+ private void OnFilterGridViewEnter (object sender, EventArgs e)
{
InvalidateCurrentRow(filterGridView);
}
- private void OnFilterGridViewLeave(object sender, EventArgs e)
+ private void OnFilterGridViewLeave (object sender, EventArgs e)
{
InvalidateCurrentRow(filterGridView);
}
- private void OnDataGridViewResize(object sender, EventArgs e)
+ private void OnDataGridViewResize (object sender, EventArgs e)
{
if (_logFileReader != null && dataGridView.RowCount > 0 && _guiStateArgs.FollowTail)
{
@@ -635,14 +636,14 @@ private void OnDataGridViewResize(object sender, EventArgs e)
}
}
- private void OnDataGridViewSelectionChanged(object sender, EventArgs e)
+ private void OnDataGridViewSelectionChanged (object sender, EventArgs e)
{
UpdateSelectionDisplay();
}
- private void OnSelectionChangedTriggerSignal(object sender, EventArgs e)
+ private void OnSelectionChangedTriggerSignal (object sender, EventArgs e)
{
- int selCount = 0;
+ var selCount = 0;
try
{
_logger.Debug("Selection changed trigger");
@@ -670,17 +671,17 @@ private void OnSelectionChangedTriggerSignal(object sender, EventArgs e)
}
}
- private void OnFilterKnobControlValueChanged(object sender, EventArgs e)
+ private void OnFilterKnobControlValueChanged (object sender, EventArgs e)
{
CheckForFilterDirty();
}
- private void OnFilterToTabButtonClick(object sender, EventArgs e)
+ private void OnFilterToTabButtonClick (object sender, EventArgs e)
{
FilterToTab();
}
- private void OnPipeDisconnected(object sender, EventArgs e)
+ private void OnPipeDisconnected (object sender, EventArgs e)
{
if (sender.GetType() == typeof(FilterPipe))
{
@@ -696,25 +697,25 @@ private void OnPipeDisconnected(object sender, EventArgs e)
}
}
- private void OnAdvancedButtonClick(object sender, EventArgs e)
+ private void OnAdvancedButtonClick (object sender, EventArgs e)
{
_showAdvanced = !_showAdvanced;
ShowAdvancedFilterPanel(_showAdvanced);
}
- private void OnFilterSplitContainerMouseDown(object sender, MouseEventArgs e)
+ private void OnFilterSplitContainerMouseDown (object sender, MouseEventArgs e)
{
((SplitContainer)sender).IsSplitterFixed = true;
}
- private void OnFilterSplitContainerMouseUp(object sender, MouseEventArgs e)
+ private void OnFilterSplitContainerMouseUp (object sender, MouseEventArgs e)
{
((SplitContainer)sender).IsSplitterFixed = false;
}
- private void OnFilterSplitContainerMouseMove(object sender, MouseEventArgs e)
+ private void OnFilterSplitContainerMouseMove (object sender, MouseEventArgs e)
{
- SplitContainer splitContainer = (SplitContainer)sender;
+ var splitContainer = (SplitContainer)sender;
if (splitContainer.IsSplitterFixed)
{
if (e.Button.Equals(MouseButtons.Left))
@@ -743,16 +744,16 @@ private void OnFilterSplitContainerMouseMove(object sender, MouseEventArgs e)
}
}
- private void OnFilterSplitContainerMouseDoubleClick(object sender, MouseEventArgs e)
+ private void OnFilterSplitContainerMouseDoubleClick (object sender, MouseEventArgs e)
{
AutoResizeFilterBox();
}
#region Context Menu
- private void OnDataGridContextMenuStripOpening(object sender, CancelEventArgs e)
+ private void OnDataGridContextMenuStripOpening (object sender, CancelEventArgs e)
{
- int lineNum = -1;
+ var lineNum = -1;
if (dataGridView.CurrentRow != null)
{
lineNum = dataGridView.CurrentRow.Index;
@@ -763,7 +764,7 @@ private void OnDataGridContextMenuStripOpening(object sender, CancelEventArgs e)
return;
}
- int refLineNum = lineNum;
+ var refLineNum = lineNum;
copyToTabToolStripMenuItem.Enabled = dataGridView.SelectedCells.Count > 0;
scrollAllTabsToTimestampToolStripMenuItem.Enabled = CurrentColumnizer.IsTimeshiftImplemented()
@@ -778,29 +779,29 @@ private void OnDataGridContextMenuStripOpening(object sender, CancelEventArgs e)
markEditModeToolStripMenuItem.Enabled = !dataGridView.CurrentCell.ReadOnly;
// Remove all "old" plugin entries
- int index = dataGridContextMenuStrip.Items.IndexOf(pluginSeparator);
+ var index = dataGridContextMenuStrip.Items.IndexOf(pluginSeparator);
if (index > 0)
{
- for (int i = index + 1; i < dataGridContextMenuStrip.Items.Count;)
+ for (var i = index + 1; i < dataGridContextMenuStrip.Items.Count;)
{
dataGridContextMenuStrip.Items.RemoveAt(i);
}
}
// Add plugin entries
- bool isAdded = false;
+ var isAdded = false;
if (PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins.Count > 0)
{
IList lines = GetSelectedContent();
foreach (IContextMenuEntry entry in PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins)
{
LogExpertCallback callback = new(this);
- string menuText = entry.GetMenuText(lines.Count, CurrentColumnizer, callback.GetLogLine(lines[0]));
+ var menuText = entry.GetMenuText(lines.Count, CurrentColumnizer, callback.GetLogLine(lines[0]));
if (menuText != null)
{
- bool disabled = menuText.StartsWith('_');
+ var disabled = menuText.StartsWith('_');
if (disabled)
{
menuText = menuText[1..];
@@ -833,7 +834,7 @@ private void OnDataGridContextMenuStripOpening(object sender, CancelEventArgs e)
{
if (fileEntry.LogWindow != this)
{
- ToolStripMenuItem item = syncTimestampsToToolStripMenuItem.DropDownItems.Add(fileEntry.Title, null, ev) as ToolStripMenuItem;
+ var item = syncTimestampsToToolStripMenuItem.DropDownItems.Add(fileEntry.Title, null, ev) as ToolStripMenuItem;
item.Tag = fileEntry;
item.Checked = TimeSyncList != null && TimeSyncList.Contains(fileEntry.LogWindow);
if (fileEntry.LogWindow.TimeSyncList != null && !fileEntry.LogWindow.TimeSyncList.Contains(this))
@@ -855,21 +856,21 @@ private void OnDataGridContextMenuStripOpening(object sender, CancelEventArgs e)
TimeSyncList.Count > 1;
}
- private void OnHandlePluginContextMenu(object sender, EventArgs args)
+ private void OnHandlePluginContextMenu (object sender, EventArgs args)
{
if (sender is ToolStripItem item)
{
- ContextMenuPluginEventArgs menuArgs = item.Tag as ContextMenuPluginEventArgs;
+ var menuArgs = item.Tag as ContextMenuPluginEventArgs;
var logLines = menuArgs.LogLines;
menuArgs.Entry.MenuSelected(logLines.Count, menuArgs.Columnizer, menuArgs.Callback.GetLogLine(logLines[0]));
}
}
- private void OnHandleSyncContextMenu(object sender, EventArgs args)
+ private void OnHandleSyncContextMenu (object sender, EventArgs args)
{
if (sender is ToolStripItem item)
{
- WindowFileEntry entry = item.Tag as WindowFileEntry;
+ var entry = item.Tag as WindowFileEntry;
if (TimeSyncList != null && TimeSyncList.Contains(entry.LogWindow))
{
@@ -883,24 +884,24 @@ private void OnHandleSyncContextMenu(object sender, EventArgs args)
}
}
- private void OnCopyToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnCopyToolStripMenuItemClick (object sender, EventArgs e)
{
CopyMarkedLinesToClipboard();
}
- private void OnCopyToTabToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnCopyToTabToolStripMenuItemClick (object sender, EventArgs e)
{
CopyMarkedLinesToTab();
}
- private void OnScrollAllTabsToTimestampToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnScrollAllTabsToTimestampToolStripMenuItemClick (object sender, EventArgs e)
{
if (CurrentColumnizer.IsTimeshiftImplemented())
{
- int currentLine = dataGridView.CurrentCellAddress.Y;
+ var currentLine = dataGridView.CurrentCellAddress.Y;
if (currentLine > 0 && currentLine < dataGridView.RowCount)
{
- int lineNum = currentLine;
+ var lineNum = currentLine;
DateTime timeStamp = GetTimestampForLine(ref lineNum, false);
if (timeStamp.Equals(DateTime.MinValue)) // means: invalid
{
@@ -912,11 +913,11 @@ private void OnScrollAllTabsToTimestampToolStripMenuItemClick(object sender, Eve
}
}
- private void OnLocateLineInOriginalFileToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnLocateLineInOriginalFileToolStripMenuItemClick (object sender, EventArgs e)
{
if (dataGridView.CurrentRow != null && FilterPipe != null)
{
- int lineNum = FilterPipe.GetOriginalLineNum(dataGridView.CurrentRow.Index);
+ var lineNum = FilterPipe.GetOriginalLineNum(dataGridView.CurrentRow.Index);
if (lineNum != -1)
{
FilterPipe.LogWindow.SelectLine(lineNum, false, true);
@@ -925,17 +926,17 @@ private void OnLocateLineInOriginalFileToolStripMenuItemClick(object sender, Eve
}
}
- private void OnToggleBoomarkToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnToggleBoomarkToolStripMenuItemClick (object sender, EventArgs e)
{
ToggleBookmark();
}
- private void OnMarkEditModeToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnMarkEditModeToolStripMenuItemClick (object sender, EventArgs e)
{
StartEditMode();
}
- private void OnLogWindowSizeChanged(object sender, EventArgs e)
+ private void OnLogWindowSizeChanged (object sender, EventArgs e)
{
//AdjustMinimumGridWith();
AdjustHighlightSplitterWidth();
@@ -943,7 +944,7 @@ private void OnLogWindowSizeChanged(object sender, EventArgs e)
#region BookMarkList
- private void OnColumnRestrictCheckBoxCheckedChanged(object sender, EventArgs e)
+ private void OnColumnRestrictCheckBoxCheckedChanged (object sender, EventArgs e)
{
columnButton.Enabled = columnRestrictCheckBox.Checked;
if (columnRestrictCheckBox.Checked) // disable when nothing to filter
@@ -960,7 +961,7 @@ private void OnColumnRestrictCheckBoxCheckedChanged(object sender, EventArgs e)
CheckForFilterDirty();
}
- private void OnColumnButtonClick(object sender, EventArgs e)
+ private void OnColumnButtonClick (object sender, EventArgs e)
{
_filterParams.CurrentColumnizer = _currentColumnizer;
FilterColumnChooser chooser = new(_filterParams);
@@ -978,7 +979,7 @@ private void OnColumnButtonClick(object sender, EventArgs e)
#region Column Header Context Menu
- private void OnDataGridViewCellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
+ private void OnDataGridViewCellContextMenuStripNeeded (object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
{
if (e.RowIndex >= 0 && e.RowIndex < dataGridView.RowCount && !dataGridView.Rows[e.RowIndex].Selected)
{
@@ -1009,7 +1010,7 @@ private void OnDataGridViewCellContextMenuStripNeeded(object sender, DataGridVie
// }
//}
- private void OnFilterGridViewCellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
+ private void OnFilterGridViewCellContextMenuStripNeeded (object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
{
if (e.ContextMenuStrip == columnContextMenuStrip)
{
@@ -1017,12 +1018,12 @@ private void OnFilterGridViewCellContextMenuStripNeeded(object sender, DataGridV
}
}
- private void OnColumnContextMenuStripOpening(object sender, CancelEventArgs e)
+ private void OnColumnContextMenuStripOpening (object sender, CancelEventArgs e)
{
Control ctl = columnContextMenuStrip.SourceControl;
- BufferedDataGridView gridView = ctl as BufferedDataGridView;
- bool frozen = false;
- if (_freezeStateMap.TryGetValue(ctl, out bool value))
+ var gridView = ctl as BufferedDataGridView;
+ var frozen = false;
+ if (_freezeStateMap.TryGetValue(ctl, out var value))
{
frozen = value;
}
@@ -1072,29 +1073,29 @@ private void OnColumnContextMenuStripOpening(object sender, CancelEventArgs e)
{
if (column.HeaderText.Length > 0)
{
- ToolStripMenuItem item = allColumnsToolStripMenuItem.DropDownItems.Add(column.HeaderText, null, ev) as ToolStripMenuItem;
+ var item = allColumnsToolStripMenuItem.DropDownItems.Add(column.HeaderText, null, ev) as ToolStripMenuItem;
item.Tag = column;
item.Enabled = !column.Frozen;
}
}
}
- private void OnHandleColumnItemContextMenu(object sender, EventArgs args)
+ private void OnHandleColumnItemContextMenu (object sender, EventArgs args)
{
if (sender is ToolStripItem item)
{
- DataGridViewColumn column = item.Tag as DataGridViewColumn;
+ var column = item.Tag as DataGridViewColumn;
column.Visible = true;
column.DataGridView.FirstDisplayedScrollingColumnIndex = column.Index;
}
}
- private void OnFreezeLeftColumnsUntilHereToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnFreezeLeftColumnsUntilHereToolStripMenuItemClick (object sender, EventArgs e)
{
Control ctl = columnContextMenuStrip.SourceControl;
- bool frozen = false;
+ var frozen = false;
- if (_freezeStateMap.TryGetValue(ctl, out bool value))
+ if (_freezeStateMap.TryGetValue(ctl, out var value))
{
frozen = value;
}
@@ -1108,9 +1109,9 @@ private void OnFreezeLeftColumnsUntilHereToolStripMenuItemClick(object sender, E
}
}
- private void OnMoveToLastColumnToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnMoveToLastColumnToolStripMenuItemClick (object sender, EventArgs e)
{
- BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView;
+ var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView;
DataGridViewColumn col = gridView.Columns[_selectedCol];
if (col != null)
{
@@ -1118,9 +1119,9 @@ private void OnMoveToLastColumnToolStripMenuItemClick(object sender, EventArgs e
}
}
- private void OnMoveLeftToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnMoveLeftToolStripMenuItemClick (object sender, EventArgs e)
{
- BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView;
+ var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView;
DataGridViewColumn col = gridView.Columns[_selectedCol];
if (col != null && col.DisplayIndex > 0)
{
@@ -1128,9 +1129,9 @@ private void OnMoveLeftToolStripMenuItemClick(object sender, EventArgs e)
}
}
- private void OnMoveRightToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnMoveRightToolStripMenuItemClick (object sender, EventArgs e)
{
- BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView;
+ var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView;
DataGridViewColumn col = gridView.Columns[_selectedCol];
if (col != null && col.DisplayIndex < gridView.Columns.Count - 1)
{
@@ -1138,33 +1139,33 @@ private void OnMoveRightToolStripMenuItemClick(object sender, EventArgs e)
}
}
- private void OnHideColumnToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnHideColumnToolStripMenuItemClick (object sender, EventArgs e)
{
- BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView;
+ var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView;
DataGridViewColumn col = gridView.Columns[_selectedCol];
col.Visible = false;
}
- private void OnRestoreColumnsToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnRestoreColumnsToolStripMenuItemClick (object sender, EventArgs e)
{
- BufferedDataGridView gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView;
+ var gridView = columnContextMenuStrip.SourceControl as BufferedDataGridView;
foreach (DataGridViewColumn col in gridView.Columns)
{
col.Visible = true;
}
}
- private void OnTimeSpreadingControlLineSelected(object sender, SelectLineEventArgs e)
+ private void OnTimeSpreadingControlLineSelected (object sender, SelectLineEventArgs e)
{
SelectLine(e.Line, false, true);
}
- private void OnBookmarkCommentToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnBookmarkCommentToolStripMenuItemClick (object sender, EventArgs e)
{
AddBookmarkAndEditComment();
}
- private void OnHighlightSelectionInLogFileToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnHighlightSelectionInLogFileToolStripMenuItemClick (object sender, EventArgs e)
{
if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl)
{
@@ -1193,7 +1194,7 @@ private void OnHighlightSelectionInLogFileToolStripMenuItemClick(object sender,
}
}
- private void OnHighlightSelectionInLogFilewordModeToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnHighlightSelectionInLogFilewordModeToolStripMenuItemClick (object sender, EventArgs e)
{
if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl)
{
@@ -1223,7 +1224,7 @@ private void OnHighlightSelectionInLogFilewordModeToolStripMenuItemClick(object
}
}
- private void OnEditModeCopyToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnEditModeCopyToolStripMenuItemClick (object sender, EventArgs e)
{
if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl)
{
@@ -1234,12 +1235,12 @@ private void OnEditModeCopyToolStripMenuItemClick(object sender, EventArgs e)
}
}
- private void OnRemoveAllToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnRemoveAllToolStripMenuItemClick (object sender, EventArgs e)
{
RemoveTempHighlights();
}
- private void OnMakePermanentToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnMakePermanentToolStripMenuItemClick (object sender, EventArgs e)
{
lock (_tempHighlightEntryListLock)
{
@@ -1252,12 +1253,12 @@ private void OnMakePermanentToolStripMenuItemClick(object sender, EventArgs e)
}
}
- private void OnMarkCurrentFilterRangeToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnMarkCurrentFilterRangeToolStripMenuItemClick (object sender, EventArgs e)
{
MarkCurrentFilterRange();
}
- private void OnFilterForSelectionToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnFilterForSelectionToolStripMenuItemClick (object sender, EventArgs e)
{
if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl)
{
@@ -1267,7 +1268,7 @@ private void OnFilterForSelectionToolStripMenuItemClick(object sender, EventArgs
}
}
- private void OnSetSelectedTextAsBookmarkCommentToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnSetSelectedTextAsBookmarkCommentToolStripMenuItemClick (object sender, EventArgs e)
{
if (dataGridView.EditingControl is DataGridViewTextBoxEditingControl ctl)
{
@@ -1275,12 +1276,12 @@ private void OnSetSelectedTextAsBookmarkCommentToolStripMenuItemClick(object sen
}
}
- private void OnDataGridViewCellClick(object sender, DataGridViewCellEventArgs e)
+ private void OnDataGridViewCellClick (object sender, DataGridViewCellEventArgs e)
{
_shouldCallTimeSync = true;
}
- private void OnDataGridViewCellDoubleClick(object sender, DataGridViewCellEventArgs e)
+ private void OnDataGridViewCellDoubleClick (object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 0)
{
@@ -1288,12 +1289,12 @@ private void OnDataGridViewCellDoubleClick(object sender, DataGridViewCellEventA
}
}
- private void OnDataGridViewOverlayDoubleClicked(object sender, OverlayEventArgs e)
+ private void OnDataGridViewOverlayDoubleClicked (object sender, OverlayEventArgs e)
{
BookmarkComment(e.BookmarkOverlay.Bookmark);
}
- private void OnFilterRegexCheckBoxMouseUp(object sender, MouseEventArgs e)
+ private void OnFilterRegexCheckBoxMouseUp (object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
@@ -1323,12 +1324,12 @@ private void OnFilterRegexCheckBoxMouseUp(object sender, MouseEventArgs e)
#region Filter-Highlight
- private void OnToggleHighlightPanelButtonClick(object sender, EventArgs e)
+ private void OnToggleHighlightPanelButtonClick (object sender, EventArgs e)
{
ToggleHighlightPanel(highlightSplitContainer.Panel2Collapsed);
}
- private void OnSaveFilterButtonClick(object sender, EventArgs e)
+ private void OnSaveFilterButtonClick (object sender, EventArgs e)
{
FilterParams newParams = _filterParams.Clone();
newParams.Color = Color.FromKnownColor(KnownColor.Black);
@@ -1336,12 +1337,12 @@ private void OnSaveFilterButtonClick(object sender, EventArgs e)
OnFilterListChanged(this);
}
- private void OnDeleteFilterButtonClick(object sender, EventArgs e)
+ private void OnDeleteFilterButtonClick (object sender, EventArgs e)
{
- int index = filterListBox.SelectedIndex;
+ var index = filterListBox.SelectedIndex;
if (index >= 0)
{
- FilterParams filterParams = (FilterParams)filterListBox.Items[index];
+ var filterParams = (FilterParams)filterListBox.Items[index];
ConfigManager.Settings.filterList.Remove(filterParams);
OnFilterListChanged(this);
if (filterListBox.Items.Count > 0)
@@ -1351,12 +1352,12 @@ private void OnDeleteFilterButtonClick(object sender, EventArgs e)
}
}
- private void OnFilterUpButtonClick(object sender, EventArgs e)
+ private void OnFilterUpButtonClick (object sender, EventArgs e)
{
- int i = filterListBox.SelectedIndex;
+ var i = filterListBox.SelectedIndex;
if (i > 0)
{
- FilterParams filterParams = (FilterParams)filterListBox.Items[i];
+ var filterParams = (FilterParams)filterListBox.Items[i];
ConfigManager.Settings.filterList.RemoveAt(i);
i--;
ConfigManager.Settings.filterList.Insert(i, filterParams);
@@ -1365,9 +1366,9 @@ private void OnFilterUpButtonClick(object sender, EventArgs e)
}
}
- private void OnFilterDownButtonClick(object sender, EventArgs e)
+ private void OnFilterDownButtonClick (object sender, EventArgs e)
{
- int i = filterListBox.SelectedIndex;
+ var i = filterListBox.SelectedIndex;
if (i < 0)
{
return;
@@ -1375,7 +1376,7 @@ private void OnFilterDownButtonClick(object sender, EventArgs e)
if (i < filterListBox.Items.Count - 1)
{
- FilterParams filterParams = (FilterParams)filterListBox.Items[i];
+ var filterParams = (FilterParams)filterListBox.Items[i];
ConfigManager.Settings.filterList.RemoveAt(i);
i++;
ConfigManager.Settings.filterList.Insert(i, filterParams);
@@ -1384,11 +1385,11 @@ private void OnFilterDownButtonClick(object sender, EventArgs e)
}
}
- private void OnFilterListBoxMouseDoubleClick(object sender, MouseEventArgs e)
+ private void OnFilterListBoxMouseDoubleClick (object sender, MouseEventArgs e)
{
if (filterListBox.SelectedIndex >= 0)
{
- FilterParams filterParams = (FilterParams)filterListBox.Items[filterListBox.SelectedIndex];
+ var filterParams = (FilterParams)filterListBox.Items[filterListBox.SelectedIndex];
FilterParams newParams = filterParams.Clone();
//newParams.historyList = ConfigManager.Settings.filterHistoryList;
this._filterParams = newParams;
@@ -1410,12 +1411,12 @@ private void OnFilterListBoxMouseDoubleClick(object sender, MouseEventArgs e)
}
}
- private void OnFilterListBoxDrawItem(object sender, DrawItemEventArgs e)
+ private void OnFilterListBoxDrawItem (object sender, DrawItemEventArgs e)
{
e.DrawBackground();
if (e.Index >= 0)
{
- FilterParams filterParams = (FilterParams)filterListBox.Items[e.Index];
+ var filterParams = (FilterParams)filterListBox.Items[e.Index];
Rectangle rectangle = new(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height);
Brush brush;
@@ -1437,12 +1438,12 @@ private void OnFilterListBoxDrawItem(object sender, DrawItemEventArgs e)
}
// Color for filter list entry
- private void OnColorToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnColorToolStripMenuItemClick (object sender, EventArgs e)
{
- int i = filterListBox.SelectedIndex;
+ var i = filterListBox.SelectedIndex;
if (i < filterListBox.Items.Count && i >= 0)
{
- FilterParams filterParams = (FilterParams)filterListBox.Items[i];
+ var filterParams = (FilterParams)filterListBox.Items[i];
ColorDialog dlg = new();
dlg.CustomColors = new[] { filterParams.Color.ToArgb() };
dlg.Color = filterParams.Color;
@@ -1454,72 +1455,72 @@ private void OnColorToolStripMenuItemClick(object sender, EventArgs e)
}
}
- private void OnFilterCaseSensitiveCheckBoxCheckedChanged(object sender, EventArgs e)
+ private void OnFilterCaseSensitiveCheckBoxCheckedChanged (object sender, EventArgs e)
{
CheckForFilterDirty();
}
- private void OnFilterRegexCheckBoxCheckedChanged(object sender, EventArgs e)
+ private void OnFilterRegexCheckBoxCheckedChanged (object sender, EventArgs e)
{
fuzzyKnobControl.Enabled = !filterRegexCheckBox.Checked;
fuzzyLabel.Enabled = !filterRegexCheckBox.Checked;
CheckForFilterDirty();
}
- private void OnInvertFilterCheckBoxCheckedChanged(object sender, EventArgs e)
+ private void OnInvertFilterCheckBoxCheckedChanged (object sender, EventArgs e)
{
CheckForFilterDirty();
}
- private void OnFilterRangeComboBoxTextChanged(object sender, EventArgs e)
+ private void OnFilterRangeComboBoxTextChanged (object sender, EventArgs e)
{
CheckForFilterDirty();
}
- private void OnFuzzyKnobControlValueChanged(object sender, EventArgs e)
+ private void OnFuzzyKnobControlValueChanged (object sender, EventArgs e)
{
CheckForFilterDirty();
}
- private void OnFilterComboBoxTextChanged(object sender, EventArgs e)
+ private void OnFilterComboBoxTextChanged (object sender, EventArgs e)
{
CheckForFilterDirty();
}
- private void OnSetBookmarksOnSelectedLinesToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnSetBookmarksOnSelectedLinesToolStripMenuItemClick (object sender, EventArgs e)
{
SetBookmarksForSelectedFilterLines();
}
- private void OnParentHighlightSettingsChanged(object sender, EventArgs e)
+ private void OnParentHighlightSettingsChanged (object sender, EventArgs e)
{
- string groupName = _guiStateArgs.HighlightGroupName;
+ var groupName = _guiStateArgs.HighlightGroupName;
SetCurrentHighlightGroup(groupName);
}
- private void OnFilterOnLoadCheckBoxMouseClick(object sender, MouseEventArgs e)
+ private void OnFilterOnLoadCheckBoxMouseClick (object sender, MouseEventArgs e)
{
HandleChangedFilterOnLoadSetting();
}
- private void OnFilterOnLoadCheckBoxKeyPress(object sender, KeyPressEventArgs e)
+ private void OnFilterOnLoadCheckBoxKeyPress (object sender, KeyPressEventArgs e)
{
HandleChangedFilterOnLoadSetting();
}
- private void OnHideFilterListOnLoadCheckBoxMouseClick(object sender, MouseEventArgs e)
+ private void OnHideFilterListOnLoadCheckBoxMouseClick (object sender, MouseEventArgs e)
{
HandleChangedFilterOnLoadSetting();
}
- private void OnFilterToTabToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnFilterToTabToolStripMenuItemClick (object sender, EventArgs e)
{
FilterToTab();
}
- private void OnTimeSyncListWindowRemoved(object sender, EventArgs e)
+ private void OnTimeSyncListWindowRemoved (object sender, EventArgs e)
{
- TimeSyncList syncList = sender as TimeSyncList;
+ var syncList = sender as TimeSyncList;
lock (_timeSyncListLock)
{
if (syncList.Count == 0 || syncList.Count == 1 && syncList.Contains(this))
@@ -1533,17 +1534,17 @@ private void OnTimeSyncListWindowRemoved(object sender, EventArgs e)
}
}
- private void OnFreeThisWindowFromTimeSyncToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnFreeThisWindowFromTimeSyncToolStripMenuItemClick (object sender, EventArgs e)
{
FreeFromTimeSync();
}
- private void OnSplitContainerSplitterMoved(object sender, SplitterEventArgs e)
+ private void OnSplitContainerSplitterMoved (object sender, SplitterEventArgs e)
{
advancedFilterSplitContainer.SplitterDistance = FILTER_ADVANCED_SPLITTER_DISTANCE;
}
- private void OnMarkFilterHitsInLogViewToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnMarkFilterHitsInLogViewToolStripMenuItemClick (object sender, EventArgs e)
{
SearchParams p = new();
p.SearchText = _filterParams.SearchText;
@@ -1552,12 +1553,12 @@ private void OnMarkFilterHitsInLogViewToolStripMenuItemClick(object sender, Even
AddSearchHitHighlightEntry(p);
}
- private void OnColumnComboBoxSelectionChangeCommitted(object sender, EventArgs e)
+ private void OnColumnComboBoxSelectionChangeCommitted (object sender, EventArgs e)
{
SelectColumn();
}
- private void OnColumnComboBoxKeyDown(object sender, KeyEventArgs e)
+ private void OnColumnComboBoxKeyDown (object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
@@ -1566,7 +1567,7 @@ private void OnColumnComboBoxKeyDown(object sender, KeyEventArgs e)
}
}
- private void OnColumnComboBoxPreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
+ private void OnColumnComboBoxPreviewKeyDown (object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt)
{
@@ -1579,7 +1580,7 @@ private void OnColumnComboBoxPreviewKeyDown(object sender, PreviewKeyDownEventAr
}
}
- private void OnBookmarkProviderBookmarkRemoved(object sender, EventArgs e)
+ private void OnBookmarkProviderBookmarkRemoved (object sender, EventArgs e)
{
if (!_isLoading)
{
@@ -1588,7 +1589,7 @@ private void OnBookmarkProviderBookmarkRemoved(object sender, EventArgs e)
}
}
- private void OnBookmarkProviderBookmarkAdded(object sender, EventArgs e)
+ private void OnBookmarkProviderBookmarkAdded (object sender, EventArgs e)
{
if (!_isLoading)
{
@@ -1597,22 +1598,22 @@ private void OnBookmarkProviderBookmarkAdded(object sender, EventArgs e)
}
}
- private void OnBookmarkProviderAllBookmarksRemoved(object sender, EventArgs e)
+ private void OnBookmarkProviderAllBookmarksRemoved (object sender, EventArgs e)
{
// nothing
}
- private void OnLogWindowLeave(object sender, EventArgs e)
+ private void OnLogWindowLeave (object sender, EventArgs e)
{
InvalidateCurrentRow();
}
- private void OnLogWindowEnter(object sender, EventArgs e)
+ private void OnLogWindowEnter (object sender, EventArgs e)
{
InvalidateCurrentRow();
}
- private void OnDataGridViewRowUnshared(object sender, DataGridViewRowEventArgs e)
+ private void OnDataGridViewRowUnshared (object sender, DataGridViewRowEventArgs e)
{
if (_logger.IsTraceEnabled)
{
@@ -1626,7 +1627,7 @@ private void OnDataGridViewRowUnshared(object sender, DataGridViewRowEventArgs e
#endregion
- private void MeasureItem(object sender, MeasureItemEventArgs e)
+ private void MeasureItem (object sender, MeasureItemEventArgs e)
{
e.ItemHeight = filterListBox.Font.Height;
}
diff --git a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs
index 1b9e9d78..b26368fa 100644
--- a/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs
+++ b/src/LogExpert.UI/Controls/LogWindow/LogWindowPrivate.cs
@@ -3,7 +3,7 @@
using System.Text.RegularExpressions;
using LogExpert.Classes.Filter;
-using LogExpert.Classes.ILogLineColumnizerCallback;
+using LogExpert.Core.Callback;
using LogExpert.Core.Classes;
using LogExpert.Core.Classes.Columnizer;
using LogExpert.Core.Classes.Filter;
@@ -612,7 +612,7 @@ private void LogEventWorker ()
while (true)
{
LogEventArgs e;
- int lastLineCount = 0;
+ var lastLineCount = 0;
lock (_logEventArgsList)
{
_logger.Info("{0} events in queue", _logEventArgsList.Count);
@@ -663,8 +663,8 @@ private void OnFileSizeChanged (LogEventArgs e)
private void UpdateGrid (LogEventArgs e)
{
- int oldRowCount = dataGridView.RowCount;
- int firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex;
+ var oldRowCount = dataGridView.RowCount;
+ var firstDisplayedLine = dataGridView.FirstDisplayedScrollingRowIndex;
if (dataGridView.CurrentCellAddress.Y >= e.LineCount)
{
@@ -676,7 +676,7 @@ private void UpdateGrid (LogEventArgs e)
{
if (dataGridView.RowCount > e.LineCount)
{
- int currentLineNum = dataGridView.CurrentCellAddress.Y;
+ var currentLineNum = dataGridView.CurrentCellAddress.Y;
dataGridView.RowCount = 0;
dataGridView.RowCount = e.LineCount;
if (_guiStateArgs.FollowTail == false)
@@ -702,7 +702,7 @@ private void UpdateGrid (LogEventArgs e)
// keep selection and view range, if no follow tail mode
if (!_guiStateArgs.FollowTail)
{
- int currentLineNum = dataGridView.CurrentCellAddress.Y;
+ var currentLineNum = dataGridView.CurrentCellAddress.Y;
currentLineNum -= e.RolloverOffset;
if (currentLineNum < 0)
{
@@ -757,7 +757,7 @@ private void UpdateGrid (LogEventArgs e)
private void CheckFilterAndHighlight (LogEventArgs e)
{
- bool noLed = true;
+ var noLed = true;
bool suppressLed;
bool setBookmark;
bool stopTail;
@@ -765,17 +765,17 @@ private void CheckFilterAndHighlight (LogEventArgs e)
if (filterTailCheckBox.Checked || _filterPipeList.Count > 0)
{
- int filterStart = e.PrevLineCount;
+ var filterStart = e.PrevLineCount;
if (e.IsRollover)
{
ShiftFilterLines(e.RolloverOffset);
filterStart -= e.RolloverOffset;
}
- bool firstStopTail = true;
+ var firstStopTail = true;
ColumnizerCallback callback = new(this);
- bool filterLineAdded = false;
- for (int i = filterStart; i < e.LineCount; ++i)
+ var filterLineAdded = false;
+ for (var i = filterStart; i < e.LineCount; ++i)
{
ILogLine line = _logFileReader.GetLogLine(i);
if (line == null)
@@ -785,7 +785,7 @@ private void CheckFilterAndHighlight (LogEventArgs e)
if (filterTailCheckBox.Checked)
{
- callback.LineNum = i;
+ callback.SetLineNum(i);
if (Util.TestFilterCondition(_filterParams, line, callback))
{
//AddFilterLineFx addFx = new AddFilterLineFx(AddFilterLine);
@@ -811,7 +811,7 @@ private void CheckFilterAndHighlight (LogEventArgs e)
if (stopTail && _guiStateArgs.FollowTail)
{
- bool wasFollow = _guiStateArgs.FollowTail;
+ var wasFollow = _guiStateArgs.FollowTail;
FollowTailChanged(false, true);
if (firstStopTail && wasFollow)
{
@@ -835,15 +835,15 @@ private void CheckFilterAndHighlight (LogEventArgs e)
}
else
{
- bool firstStopTail = true;
- int startLine = e.PrevLineCount;
+ var firstStopTail = true;
+ var startLine = e.PrevLineCount;
if (e.IsRollover)
{
ShiftFilterLines(e.RolloverOffset);
startLine -= e.RolloverOffset;
}
- for (int i = startLine; i < e.LineCount; ++i)
+ for (var i = startLine; i < e.LineCount; ++i)
{
ILogLine line = _logFileReader.GetLogLine(i);
if (line != null)
@@ -860,7 +860,7 @@ private void CheckFilterAndHighlight (LogEventArgs e)
if (stopTail && _guiStateArgs.FollowTail)
{
- bool wasFollow = _guiStateArgs.FollowTail;
+ var wasFollow = _guiStateArgs.FollowTail;
FollowTailChanged(false, true);
if (firstStopTail && wasFollow)
{
@@ -898,8 +898,7 @@ private void LaunchHighlightPlugins (IList matchingList, int lin
if (plugin != null)
{
ActionPluginExecuteFx fx = plugin.Execute;
- fx.BeginInvoke(entry.SearchText, entry.ActionEntry.ActionParam, callback,
- CurrentColumnizer, null, null);
+ fx.BeginInvoke(entry.SearchText, entry.ActionEntry.ActionParam, callback, CurrentColumnizer, null, null);
}
}
}
@@ -907,22 +906,16 @@ private void LaunchHighlightPlugins (IList matchingList, int lin
private void PreSelectColumnizer (ILogLineColumnizer columnizer)
{
- if (columnizer != null)
- {
- CurrentColumnizer = _forcedColumnizerForLoading = columnizer;
- }
- else
- {
- CurrentColumnizer = _forcedColumnizerForLoading =
- ColumnizerPicker.FindColumnizer(FileName, _logFileReader, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers);
- }
+ CurrentColumnizer = columnizer != null
+ ? (_forcedColumnizerForLoading = columnizer)
+ : (_forcedColumnizerForLoading = ColumnizerPicker.FindColumnizer(FileName, _logFileReader, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers));
}
private void SetColumnizer (ILogLineColumnizer columnizer)
{
columnizer = ColumnizerPicker.FindReplacementForAutoColumnizer(FileName, _logFileReader, columnizer, PluginRegistry.PluginRegistry.Instance.RegisteredColumnizers);
- int timeDiff = 0;
+ var timeDiff = 0;
if (CurrentColumnizer != null && CurrentColumnizer.IsTimeshiftImplemented())
{
timeDiff = CurrentColumnizer.GetTimeOffset();
@@ -941,19 +934,19 @@ private void SetColumnizerInternal (ILogLineColumnizer columnizer)
_logger.Info("SetColumnizerInternal(): {0}", columnizer.GetName());
ILogLineColumnizer oldColumnizer = CurrentColumnizer;
- bool oldColumnizerIsXmlType = CurrentColumnizer is ILogLineXmlColumnizer;
- bool oldColumnizerIsPreProcess = CurrentColumnizer is IPreProcessColumnizer;
- bool mustReload = false;
+ var oldColumnizerIsXmlType = CurrentColumnizer is ILogLineXmlColumnizer;
+ var oldColumnizerIsPreProcess = CurrentColumnizer is IPreProcessColumnizer;
+ var mustReload = false;
// Check if the filtered columns disappeared, if so must refresh the UI
if (_filterParams.ColumnRestrict)
{
- string[] newColumns = columnizer != null ? columnizer.GetColumnNames() : Array.Empty();
- bool colChanged = false;
+ var newColumns = columnizer != null ? columnizer.GetColumnNames() : Array.Empty();
+ var colChanged = false;
if (dataGridView.ColumnCount - 2 == newColumns.Length) // two first columns are 'marker' and 'line number'
{
- for (int i = 0; i < newColumns.Length; i++)
+ for (var i = 0; i < newColumns.Length; i++)
{
if (dataGridView.Columns[i].HeaderText != newColumns[i])
{
@@ -1072,7 +1065,7 @@ private void SetColumnizerInternal (ILogLineColumnizer columnizer)
columnComboBox.Items.Clear();
- foreach (string columnName in columnizer.GetColumnNames())
+ foreach (var columnName in columnizer.GetColumnNames())
{
columnComboBox.Items.Add(columnName);
}
@@ -1149,7 +1142,7 @@ private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, Buffered
matchList = MergeHighlightMatchEntries(matchList, hme);
- int leftPad = e.CellStyle.Padding.Left;
+ var leftPad = e.CellStyle.Padding.Left;
RectangleF rect = new(e.CellBounds.Left + leftPad, e.CellBounds.Top, e.CellBounds.Width,
e.CellBounds.Height);
Rectangle borderWidths = PaintHelper.BorderWidths(e.AdvancedBorderStyle);
@@ -1192,7 +1185,7 @@ private void PaintHighlightedCell (DataGridViewCellPaintingEventArgs e, Buffered
Brush bgBrush = matchEntry.HilightEntry.BackgroundColor != Color.Empty
? new SolidBrush(matchEntry.HilightEntry.BackgroundColor)
: null;
- string matchWord = column.DisplayValue.Substring(matchEntry.StartPos, matchEntry.Length);
+ var matchWord = column.DisplayValue.Substring(matchEntry.StartPos, matchEntry.Length);
Size wordSize = TextRenderer.MeasureText(e.Graphics, matchWord, font, proposedSize, flags);
wordSize.Height = e.CellBounds.Height;
Rectangle wordRect = new(wordPos, wordSize);
@@ -1232,8 +1225,8 @@ private IList MergeHighlightMatchEntries (IList MergeHighlightMatchEntries (IList MergeHighlightMatchEntries (IList 0)
{
HighlightEntry currentEntry = entryArray[0];
- int lastStartPos = 0;
- int pos = 0;
+ var lastStartPos = 0;
+ var pos = 0;
for (; pos < entryArray.Length; ++pos)
{
@@ -1474,7 +1467,7 @@ private void SyncTimestampDisplayWorker ()
while (!_shouldTimestampDisplaySyncingCancel)
{
- bool signaled = _timeShiftSyncTimerEvent.WaitOne(WAIT_TIME, true);
+ var signaled = _timeShiftSyncTimerEvent.WaitOne(WAIT_TIME, true);
_timeShiftSyncTimerEvent.Reset();
if (!signaled)
{
@@ -1483,10 +1476,10 @@ private void SyncTimestampDisplayWorker ()
}
// timeout with no new Trigger -> update display
- int lineNum = _timeShiftSyncLine;
+ var lineNum = _timeShiftSyncLine;
if (lineNum >= 0 && lineNum < dataGridView.RowCount)
{
- int refLine = lineNum;
+ var refLine = lineNum;
DateTime timeStamp = GetTimestampForLine(ref refLine, true);
if (!timeStamp.Equals(DateTime.MinValue) && !_shouldTimestampDisplaySyncingCancel)
{
@@ -1505,14 +1498,14 @@ private void SyncTimestampDisplayWorker ()
// show time difference between 2 selected lines
if (dataGridView.SelectedRows.Count == 2)
{
- int row1 = dataGridView.SelectedRows[0].Index;
- int row2 = dataGridView.SelectedRows[1].Index;
+ var row1 = dataGridView.SelectedRows[0].Index;
+ var row2 = dataGridView.SelectedRows[1].Index;
if (row1 > row2)
{
(row2, row1) = (row1, row2);
}
- int refLine = row1;
+ var refLine = row1;
DateTime timeStamp1 = GetTimestampForLine(ref refLine, false);
refLine = row2;
DateTime timeStamp2 = GetTimestampForLine(ref refLine, false);
@@ -1545,7 +1538,7 @@ private void SyncFilterGridPos ()
{
if (_filterResultList.Count > 0)
{
- int index = _filterResultList.BinarySearch(dataGridView.CurrentRow.Index);
+ var index = _filterResultList.BinarySearch(dataGridView.CurrentRow.Index);
if (index < 0)
{
index = ~index;
@@ -1584,13 +1577,13 @@ private int Search (SearchParams searchParams)
return -1;
}
- int lineNum = searchParams.IsFromTop && !searchParams.IsFindNext
+ var lineNum = searchParams.IsFromTop && !searchParams.IsFindNext
? 0
: searchParams.CurrentLine;
- string lowerSearchText = searchParams.SearchText.ToLower();
- int count = 0;
- bool hasWrapped = false;
+ var lowerSearchText = searchParams.SearchText.ToLower();
+ var count = 0;
+ var hasWrapped = false;
while (true)
{
@@ -1702,7 +1695,7 @@ private void SelectLine (int line, bool triggerSyncCall, bool shouldScroll)
try
{
_shouldCallTimeSync = triggerSyncCall;
- bool wasCancelled = _shouldCancel;
+ var wasCancelled = _shouldCancel;
_shouldCancel = false;
_isSearching = false;
StatusLineText("");
@@ -1774,7 +1767,7 @@ private void UpdateEditColumnDisplay (DataGridViewTextBoxEditingControl editCont
// prevents key events after edit mode has ended
if (dataGridView.EditingControl != null)
{
- int pos = editControl.SelectionStart + editControl.SelectionLength;
+ var pos = editControl.SelectionStart + editControl.SelectionLength;
StatusLineText(" " + pos);
_logger.Debug("SelStart: {0}, SelLen: {1}", editControl.SelectionStart, editControl.SelectionLength);
}
@@ -1782,7 +1775,7 @@ private void UpdateEditColumnDisplay (DataGridViewTextBoxEditingControl editCont
private void SelectPrevHighlightLine ()
{
- int lineNum = dataGridView.CurrentCellAddress.Y;
+ var lineNum = dataGridView.CurrentCellAddress.Y;
while (lineNum > 0)
{
lineNum--;
@@ -1801,7 +1794,7 @@ private void SelectPrevHighlightLine ()
private void SelectNextHighlightLine ()
{
- int lineNum = dataGridView.CurrentCellAddress.Y;
+ var lineNum = dataGridView.CurrentCellAddress.Y;
while (lineNum < _logFileReader.LineCount)
{
lineNum++;
@@ -1861,7 +1854,7 @@ private void ShiftRowHeightList (int offset)
SortedList newList = [];
foreach (RowHeightEntry entry in _rowHeightList.Values)
{
- int line = entry.LineNum - offset;
+ var line = entry.LineNum - offset;
if (line >= 0)
{
entry.LineNum = line;
@@ -1895,7 +1888,7 @@ private void LoadFilterPipes ()
if (_filterPipeList.Count > 0)
{
- for (int i = 0; i < dataGridView.RowCount; ++i)
+ for (var i = 0; i < dataGridView.RowCount; ++i)
{
ProcessFilterPipes(i);
}
@@ -1968,7 +1961,7 @@ private async void FilterSearch (string text)
_filterParams.LowerSearchText = text.ToLower();
ConfigManager.Settings.filterHistoryList.Remove(text);
ConfigManager.Settings.filterHistoryList.Insert(0, text);
- int maxHistory = ConfigManager.Settings.Preferences.maximumFilterEntries;
+ var maxHistory = ConfigManager.Settings.Preferences.maximumFilterEntries;
if (ConfigManager.Settings.filterHistoryList.Count > maxHistory)
{
@@ -1976,7 +1969,7 @@ private async void FilterSearch (string text)
}
filterComboBox.Items.Clear();
- foreach (string item in ConfigManager.Settings.filterHistoryList)
+ foreach (var item in ConfigManager.Settings.filterHistoryList)
{
filterComboBox.Items.Add(item);
}
@@ -1995,7 +1988,7 @@ private async void FilterSearch (string text)
}
filterRangeComboBox.Items.Clear();
- foreach (string item in ConfigManager.Settings.filterRangeHistoryList)
+ foreach (var item in ConfigManager.Settings.filterRangeHistoryList)
{
filterRangeComboBox.Items.Add(item);
}
@@ -2046,7 +2039,7 @@ private async void FilterSearch (string text)
FilterFxAction = settings.Preferences.multiThreadFilter ? MultiThreadedFilter : Filter;
//Task.Run(() => fx.Invoke(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList));
- Task filterFxActionTask = Task.Run(() => Filter(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList));
+ var filterFxActionTask = Task.Run(() => Filter(_filterParams, _filterResultList, _lastFilterLinesList, _filterHitList));
await filterFxActionTask;
FilterComplete();
@@ -2089,7 +2082,7 @@ private void Filter (FilterParams filterParams, List filterResultLines, Lis
try
{
filterParams.Reset();
- int lineNum = 0;
+ var lineNum = 0;
//AddFilterLineFx addFx = new AddFilterLineFx(AddFilterLine);
ColumnizerCallback callback = new(this);
while (true)
@@ -2157,7 +2150,7 @@ private IList GetAdditionalFilterResults (FilterParams filterParams, int li
}
// back spread
- for (int i = filterParams.SpreadBefore; i > 0; --i)
+ for (var i = filterParams.SpreadBefore; i > 0; --i)
{
if (lineNum - i > 0)
{
@@ -2175,7 +2168,7 @@ private IList GetAdditionalFilterResults (FilterParams filterParams, int li
}
// after spread
- for (int i = 1; i <= filterParams.SpreadBehind; ++i)
+ for (var i = 1; i <= filterParams.SpreadBehind; ++i)
{
if (lineNum + i < _logFileReader.LineCount)
{
@@ -2407,9 +2400,9 @@ private void ShiftFilterLines (int offset)
List newFilterList = [];
lock (_filterResultList)
{
- foreach (int lineNum in _filterResultList)
+ foreach (var lineNum in _filterResultList)
{
- int line = lineNum - offset;
+ var line = lineNum - offset;
if (line >= 0)
{
newFilterList.Add(line);
@@ -2420,9 +2413,9 @@ private void ShiftFilterLines (int offset)
}
newFilterList = [];
- foreach (int lineNum in _filterHitList)
+ foreach (var lineNum in _filterHitList)
{
- int line = lineNum - offset;
+ var line = lineNum - offset;
if (line >= 0)
{
newFilterList.Add(line);
@@ -2431,7 +2424,7 @@ private void ShiftFilterLines (int offset)
_filterHitList = newFilterList;
- int count = SPREAD_MAX;
+ var count = SPREAD_MAX;
if (_filterResultList.Count < SPREAD_MAX)
{
count = _filterResultList.Count;
@@ -2522,8 +2515,8 @@ private void AdjustMinimumGridWith ()
//this.dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells);
AutoResizeColumns(dataGridView);
- int width = dataGridView.Columns.GetColumnsWidth(DataGridViewElementStates.Visible);
- int diff = dataGridView.Width - width;
+ var width = dataGridView.Columns.GetColumnsWidth(DataGridViewElementStates.Visible);
+ var diff = dataGridView.Width - width;
if (diff > 0)
{
diff -= dataGridView.RowHeadersWidth / 2;
@@ -2555,7 +2548,7 @@ private void DisplayCurrentFileOnStatusline ()
{
if (dataGridView.CurrentRow != null && dataGridView.CurrentRow.Index > -1)
{
- string fileName = _logFileReader.GetLogFileNameForLine(dataGridView.CurrentRow.Index);
+ var fileName = _logFileReader.GetLogFileNameForLine(dataGridView.CurrentRow.Index);
if (fileName != null)
{
StatusLineText(Util.GetNameFromPath(fileName));
@@ -2585,13 +2578,13 @@ private void UpdateFilterHistoryFromSettings ()
{
ConfigManager.Settings.filterHistoryList = ConfigManager.Settings.filterHistoryList;
filterComboBox.Items.Clear();
- foreach (string item in ConfigManager.Settings.filterHistoryList)
+ foreach (var item in ConfigManager.Settings.filterHistoryList)
{
filterComboBox.Items.Add(item);
}
filterRangeComboBox.Items.Clear();
- foreach (string item in ConfigManager.Settings.filterRangeHistoryList)
+ foreach (var item in ConfigManager.Settings.filterRangeHistoryList)
{
filterRangeComboBox.Items.Add(item);
}
@@ -2671,7 +2664,7 @@ private void WriteFilterToTab ()
FilterPipe pipe = new(_filterParams.Clone(), this);
lock (_filterResultList)
{
- string namePrefix = "->F";
+ var namePrefix = "->F";
string title;
if (IsTempFile)
{
@@ -2706,10 +2699,10 @@ private void WritePipeToTab (FilterPipe pipe, IList lineNumberList, string
}
pipe.Closed += OnPipeDisconnected;
- int count = 0;
+ var count = 0;
pipe.OpenFile();
LogExpertCallback callback = new(this);
- foreach (int i in lineNumberList)
+ foreach (var i in lineNumberList)
{
if (_shouldCancel)
{
@@ -2741,7 +2734,7 @@ private void WriteFilterToTabFinished (FilterPipe pipe, string name, Persistence
_isSearching = false;
if (!_shouldCancel)
{
- string title = name;
+ var title = name;
ILogLineColumnizer preProcessColumnizer = null;
if (CurrentColumnizer is not ILogLineXmlColumnizer)
{
@@ -2830,7 +2823,7 @@ private void ProcessFilterPipes (int lineNum)
IList filterResult =
GetAdditionalFilterResults(pipe.FilterParams, lineNum, pipe.LastLinesHistoryList);
pipe.OpenFile();
- foreach (int line in filterResult)
+ foreach (var line in filterResult)
{
pipe.LastLinesHistoryList.Add(line);
if (pipe.LastLinesHistoryList.Count > SPREAD_MAX * 2)
@@ -2839,7 +2832,7 @@ private void ProcessFilterPipes (int lineNum)
}
ILogLine textLine = _logFileReader.GetLogLine(line);
- bool fileOk = pipe.WriteToPipe(textLine, line);
+ var fileOk = pipe.WriteToPipe(textLine, line);
if (!fileOk)
{
deleteList.Add(pipe);
@@ -2884,7 +2877,7 @@ private void CopyMarkedLinesToClipboard ()
var xmlColumnizer = _currentColumnizer as ILogLineXmlColumnizer;
- foreach (int lineNum in lineNumList)
+ foreach (var lineNum in lineNumList)
{
ILogLine line = _logFileReader.GetLogLine(lineNum);
if (xmlColumnizer != null)
@@ -2968,7 +2961,7 @@ private void SetTimestampLimits ()
return;
}
- int line = 0;
+ var line = 0;
_guiStateArgs.MinTimestamp = GetTimestampForLineForward(ref line, true);
line = dataGridView.RowCount - 1;
_guiStateArgs.MaxTimestamp = GetTimestampForLine(ref line, true);
@@ -3003,11 +2996,11 @@ private void BookmarkComment (Bookmark bookmark)
///
private string CalculateColumnNames (FilterParams filter)
{
- string names = string.Empty;
+ var names = string.Empty;
if (filter.ColumnRestrict)
{
- foreach (int colIndex in filter.ColumnList)
+ foreach (var colIndex in filter.ColumnList)
{
if (colIndex < dataGridView.Columns.GetColumnCount(DataGridViewElementStates.None) - 2)
{
@@ -3036,7 +3029,7 @@ private void ApplyFrozenState (BufferedDataGridView gridView)
foreach (DataGridViewColumn col in dict.Values)
{
col.Frozen = _freezeStateMap.ContainsKey(gridView) && _freezeStateMap[gridView];
- bool sel = col.HeaderCell.Selected;
+ var sel = col.HeaderCell.Selected;
if (col.Index == _selectedCol)
{
break;
@@ -3079,12 +3072,12 @@ private void InitPatternWindow ()
private void TestStatistic (PatternArgs patternArgs)
{
- int beginLine = patternArgs.StartLine;
+ var beginLine = patternArgs.StartLine;
_logger.Info("TestStatistics() called with start line {0}", beginLine);
_patternArgs = patternArgs;
- int num = beginLine + 1; //this.dataGridView.RowCount;
+ var num = beginLine + 1; //this.dataGridView.RowCount;
_progressEventArgs.MinValue = 0;
_progressEventArgs.MaxValue = dataGridView.RowCount;
@@ -3097,11 +3090,11 @@ private void TestStatistic (PatternArgs patternArgs)
Dictionary processedLinesDict = [];
List blockList = [];
- int blockId = 0;
+ var blockId = 0;
_isSearching = true;
_shouldCancel = false;
- int searchLine = -1;
- for (int i = beginLine; i < num && !_shouldCancel; ++i)
+ var searchLine = -1;
+ for (var i = beginLine; i < num && !_shouldCancel; ++i)
{
if (processedLinesDict.ContainsKey(i))
{
@@ -3109,7 +3102,7 @@ private void TestStatistic (PatternArgs patternArgs)
}
PatternBlock block;
- int maxBlockLen = patternArgs.EndLine - patternArgs.StartLine;
+ var maxBlockLen = patternArgs.EndLine - patternArgs.StartLine;
//int searchLine = i + 1;
_logger.Debug("TestStatistic(): i={0} searchLine={1}", i, searchLine);
//bool firstBlock = true;
@@ -3172,7 +3165,7 @@ private void TestStatistic (PatternArgs patternArgs)
private void addBlockTargetLinesToDict (Dictionary dict, PatternBlock block)
{
- foreach (int lineNum in block.targetLines.Keys)
+ foreach (var lineNum in block.targetLines.Keys)
{
if (!dict.ContainsKey(lineNum))
{
@@ -3204,7 +3197,7 @@ private PatternBlock FindExistingBlock (PatternBlock block, List b
private PatternBlock DetectBlock (int startNum, int startLineToSearch, int maxBlockLen, int maxDiffInBlock,
int maxMisses, Dictionary processedLinesDict)
{
- int targetLine = FindSimilarLine(startNum, startLineToSearch, processedLinesDict);
+ var targetLine = FindSimilarLine(startNum, startLineToSearch, processedLinesDict);
if (targetLine == -1)
{
return null;
@@ -3212,12 +3205,12 @@ private PatternBlock DetectBlock (int startNum, int startLineToSearch, int maxBl
PatternBlock block = new();
block.startLine = startNum;
- int srcLine = block.startLine;
+ var srcLine = block.startLine;
block.targetStart = targetLine;
- int srcMisses = 0;
+ var srcMisses = 0;
block.srcLines.Add(srcLine, srcLine);
//block.targetLines.Add(targetLine, targetLine);
- int len = 0;
+ var len = 0;
QualityInfo qi = new();
qi.quality = block.weigth;
block.qualityInfoList[targetLine] = qi;
@@ -3233,7 +3226,7 @@ private PatternBlock DetectBlock (int startNum, int startLineToSearch, int maxBl
break;
}
- int nextTargetLine = FindSimilarLine(srcLine, targetLine + 1, processedLinesDict);
+ var nextTargetLine = FindSimilarLine(srcLine, targetLine + 1, processedLinesDict);
if (nextTargetLine > -1 && nextTargetLine - targetLine - 1 <= maxDiffInBlock)
{
block.weigth += maxDiffInBlock - (nextTargetLine - targetLine - 1) + 1;
@@ -3242,8 +3235,8 @@ private PatternBlock DetectBlock (int startNum, int startLineToSearch, int maxBl
block.srcLines.Add(srcLine, srcLine);
if (nextTargetLine - targetLine > 1)
{
- int tempWeight = block.weigth;
- for (int tl = targetLine + 1; tl < nextTargetLine; ++tl)
+ var tempWeight = block.weigth;
+ for (var tl = targetLine + 1; tl < nextTargetLine; ++tl)
{
qi = new QualityInfo();
qi.quality = --tempWeight;
@@ -3275,7 +3268,7 @@ private PatternBlock DetectBlock (int startNum, int startLineToSearch, int maxBl
qi = new QualityInfo();
qi.quality = block.weigth;
block.qualityInfoList[targetLine] = qi;
- for (int k = block.targetStart; k <= block.targetEnd; ++k)
+ for (var k = block.targetStart; k <= block.targetEnd; ++k)
{
block.targetLines.Add(k, k);
}
@@ -3289,20 +3282,20 @@ private void PrepareDict ()
Regex regex = new("\\d");
Regex regex2 = new("\\S");
- int num = _logFileReader.LineCount;
- for (int i = 0; i < num; ++i)
+ var num = _logFileReader.LineCount;
+ for (var i = 0; i < num; ++i)
{
- string msg = GetMsgForLine(i);
+ var msg = GetMsgForLine(i);
if (msg != null)
{
msg = msg.ToLower();
msg = regex.Replace(msg, "0");
msg = regex2.Replace(msg, " ");
- char[] chars = msg.ToCharArray();
- int value = 0;
- int numOfE = 0;
- int numOfA = 0;
- int numOfI = 0;
+ var chars = msg.ToCharArray();
+ var value = 0;
+ var numOfE = 0;
+ var numOfA = 0;
+ var numOfI = 0;
foreach (var t in chars)
{
value += t;
@@ -3330,10 +3323,10 @@ private void PrepareDict ()
private int _FindSimilarLine (int srcLine, int startLine)
{
- int value = _lineHashList[srcLine];
+ var value = _lineHashList[srcLine];
- int num = _lineHashList.Count;
- for (int i = startLine; i < num; ++i)
+ var num = _lineHashList.Count;
+ for (var i = startLine; i < num; ++i)
{
if (Math.Abs(_lineHashList[i] - value) < 3)
{
@@ -3360,16 +3353,16 @@ private void ResetCache (int num)
private int FindSimilarLine (int srcLine, int startLine, Dictionary processedLinesDict)
{
- int threshold = _patternArgs.Fuzzy;
+ var threshold = _patternArgs.Fuzzy;
- bool prepared = false;
+ var prepared = false;
Regex regex = null;
Regex regex2 = null;
string msgToFind = null;
CultureInfo culture = CultureInfo.CurrentCulture;
- int num = _logFileReader.LineCount;
- for (int i = startLine; i < num; ++i)
+ var num = _logFileReader.LineCount;
+ for (var i = startLine; i < num; ++i)
{
if (processedLinesDict.ContainsKey(i))
{
@@ -3396,12 +3389,12 @@ private int FindSimilarLine (int srcLine, int startLine, Dictionary pr
prepared = true;
}
- string msg = GetMsgForLine(i);
+ var msg = GetMsgForLine(i);
if (msg != null)
{
msg = regex.Replace(msg, "0");
msg = regex2.Replace(msg, " ");
- int lenDiff = Math.Abs(msg.Length - msgToFind.Length);
+ var lenDiff = Math.Abs(msg.Length - msgToFind.Length);
if (lenDiff > threshold)
{
//this.similarCache[srcLine, i] = lenDiff;
@@ -3409,7 +3402,7 @@ private int FindSimilarLine (int srcLine, int startLine, Dictionary pr
}
msg = msg.ToLower(culture);
- int distance = Util.YetiLevenshtein(msgToFind, msg);
+ var distance = Util.YetiLevenshtein(msgToFind, msg);
//this.similarCache[srcLine, i] = distance;
if (distance < threshold)
{
@@ -3433,7 +3426,7 @@ private string GetMsgForLine (int i)
private void ChangeRowHeight (bool decrease)
{
- int rowNum = dataGridView.CurrentCellAddress.Y;
+ var rowNum = dataGridView.CurrentCellAddress.Y;
if (rowNum < 0 || rowNum >= dataGridView.RowCount)
{
return;
@@ -3504,7 +3497,7 @@ private void AddBookmarkAtLineSilently (int lineNum)
private void AddBookmarkAndEditComment ()
{
- int lineNum = dataGridView.CurrentCellAddress.Y;
+ var lineNum = dataGridView.CurrentCellAddress.Y;
if (!_bookmarkProvider.IsBookmarkAtLine(lineNum))
{
ToggleBookmark();
@@ -3515,7 +3508,7 @@ private void AddBookmarkAndEditComment ()
private void AddBookmarkComment (string text)
{
- int lineNum = dataGridView.CurrentCellAddress.Y;
+ var lineNum = dataGridView.CurrentCellAddress.Y;
Bookmark bookmark;
if (!_bookmarkProvider.IsBookmarkAtLine(lineNum))
{
@@ -3542,7 +3535,7 @@ private void MarkCurrentFilterRange ()
{
SetCellSelectionMode(false);
_noSelectionUpdates = true;
- for (int i = range.StartLine; i <= range.EndLine; ++i)
+ for (var i = range.StartLine; i <= range.EndLine; ++i)
{
dataGridView.Rows[i].Selected = true;
}
@@ -3576,7 +3569,7 @@ private void SetBookmarksForSelectedFilterLines ()
{
foreach (DataGridViewRow row in filterGridView.SelectedRows)
{
- int lineNum = _filterResultList[row.Index];
+ var lineNum = _filterResultList[row.Index];
AddBookmarkAtLineSilently(lineNum);
}
}
@@ -3641,8 +3634,8 @@ private void AddSlaveToTimesync (LogWindow slave)
TimeSyncList = slave.TimeSyncList;
}
- int currentLineNum = dataGridView.CurrentCellAddress.Y;
- int refLine = currentLineNum;
+ var currentLineNum = dataGridView.CurrentCellAddress.Y;
+ var refLine = currentLineNum;
DateTime timeStamp = GetTimestampForLine(ref refLine, true);
if (!timeStamp.Equals(DateTime.MinValue) && !_shouldTimestampDisplaySyncingCancel)
{
@@ -3727,12 +3720,12 @@ private DataGridViewColumn GetColumnByName (BufferedDataGridView dataGridView, s
private void SelectColumn ()
{
- string colName = columnComboBox.SelectedItem as string;
+ var colName = columnComboBox.SelectedItem as string;
DataGridViewColumn col = GetColumnByName(dataGridView, colName);
if (col != null && !col.Frozen)
{
dataGridView.FirstDisplayedScrollingColumnIndex = col.Index;
- int currentLine = dataGridView.CurrentCellAddress.Y;
+ var currentLine = dataGridView.CurrentCellAddress.Y;
if (currentLine >= 0)
{
dataGridView.CurrentCell = dataGridView.Rows[dataGridView.CurrentCellAddress.Y].Cells[col.Index];
diff --git a/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs b/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs
index 4852acea..2a822e02 100644
--- a/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs
+++ b/src/LogExpert.UI/Controls/LogWindow/RangeFinder.cs
@@ -1,7 +1,8 @@
-using LogExpert.Classes.ILogLineColumnizerCallback;
+using LogExpert.Core.Callback;
using LogExpert.Core.Classes;
using LogExpert.Core.Classes.Filter;
using LogExpert.Core.Entities;
+
using NLog;
using Range = LogExpert.Core.Entities.Range;
diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs
index f787bf21..47521d25 100644
--- a/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs
+++ b/src/LogExpert.UI/Controls/LogWindow/TimeSpreadCalculator.cs
@@ -1,6 +1,7 @@
-using LogExpert.Classes.ILogLineColumnizerCallback;
+using LogExpert.Core.Callback;
using LogExpert.Core.Classes;
using LogExpert.Core.Interface;
+
using NLog;
using System;
diff --git a/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs b/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs
index 67d5c392..5ed65d2c 100644
--- a/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs
+++ b/src/LogExpert.UI/Controls/LogWindow/TimeSyncList.cs
@@ -1,101 +1,100 @@
-namespace LogExpert.UI.Controls.LogWindow
+namespace LogExpert.UI.Controls.LogWindow;
+
+///
+/// Holds all windows which are in sync via timestamp
+///
+public class TimeSyncList
{
- ///
- /// Holds all windows which are in sync via timestamp
- ///
- internal class TimeSyncList
- {
- #region Fields
+ #region Fields
- private readonly IList logWindowList = new List();
+ private readonly IList logWindowList = new List();
- #endregion
+ #endregion
- #region Delegates
+ #region Delegates
- public delegate void WindowRemovedEventHandler(object sender, EventArgs e);
+ public delegate void WindowRemovedEventHandler (object sender, EventArgs e);
- #endregion
+ #endregion
- #region Events
+ #region Events
- public event WindowRemovedEventHandler WindowRemoved;
+ public event WindowRemovedEventHandler WindowRemoved;
- #endregion
+ #endregion
- #region Properties
+ #region Properties
- public DateTime CurrentTimestamp { get; set; }
+ public DateTime CurrentTimestamp { get; set; }
- public int Count
- {
- get { return logWindowList.Count; }
- }
+ public int Count
+ {
+ get { return logWindowList.Count; }
+ }
- #endregion
+ #endregion
- #region Public methods
+ #region Public methods
- public void AddWindow(LogWindow logWindow)
+ public void AddWindow (LogWindow logWindow)
+ {
+ lock (logWindowList)
{
- lock (logWindowList)
+ if (!logWindowList.Contains(logWindow))
{
- if (!logWindowList.Contains(logWindow))
- {
- logWindowList.Add(logWindow);
- }
+ logWindowList.Add(logWindow);
}
}
+ }
- public void RemoveWindow(LogWindow logWindow)
+ public void RemoveWindow (LogWindow logWindow)
+ {
+ lock (logWindowList)
{
- lock (logWindowList)
- {
- logWindowList.Remove(logWindow);
- }
- OnWindowRemoved();
+ logWindowList.Remove(logWindow);
}
+ OnWindowRemoved();
+ }
- ///
- /// Scrolls all LogWindows to the given timestamp
- ///
- ///
- ///
- public void NavigateToTimestamp(DateTime timestamp, LogWindow sender)
+ ///
+ /// Scrolls all LogWindows to the given timestamp
+ ///
+ ///
+ ///
+ public void NavigateToTimestamp (DateTime timestamp, LogWindow sender)
+ {
+ CurrentTimestamp = timestamp;
+ lock (logWindowList)
{
- CurrentTimestamp = timestamp;
- lock (logWindowList)
+ foreach (LogWindow logWindow in logWindowList)
{
- foreach (LogWindow logWindow in logWindowList)
+ if (sender != logWindow)
{
- if (sender != logWindow)
- {
- logWindow.ScrollToTimestamp(timestamp, false, false);
- }
+ logWindow.ScrollToTimestamp(timestamp, false, false);
}
}
}
+ }
- public bool Contains(LogWindow logWindow)
- {
- return logWindowList.Contains(logWindow);
- }
+ public bool Contains (LogWindow logWindow)
+ {
+ return logWindowList.Contains(logWindow);
+ }
- #endregion
+ #endregion
- #region Private Methods
+ #region Private Methods
- private void OnWindowRemoved()
+ private void OnWindowRemoved ()
+ {
+ if (WindowRemoved != null)
{
- if (WindowRemoved != null)
- {
- WindowRemoved(this, new EventArgs());
- }
+ WindowRemoved(this, new EventArgs());
}
-
- #endregion
}
+
+ #endregion
}
\ No newline at end of file
diff --git a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs
index 6259de88..eb79c2b7 100644
--- a/src/LogExpert.UI/Dialogs/BookmarkWindow.cs
+++ b/src/LogExpert.UI/Dialogs/BookmarkWindow.cs
@@ -1,11 +1,13 @@
-using LogExpert.Core.Config;
+using LogExpert.Core.Config;
using LogExpert.Core.Entities;
using LogExpert.Core.Enums;
using LogExpert.Core.Interface;
using LogExpert.UI.Entities;
using LogExpert.UI.Extensions.Forms;
using LogExpert.UI.Interface;
+
using NLog;
+
using WeifenLuo.WinFormsUI.Docking;
namespace LogExpert.Dialogs;
@@ -26,7 +28,7 @@ public partial class BookmarkWindow : DockContent, ISharedToolWindow, IBookmarkV
#region cTor
- public BookmarkWindow()
+ public BookmarkWindow ()
{
InitializeComponent();
AutoScaleDimensions = new SizeF(96F, 96F);
@@ -42,7 +44,7 @@ public BookmarkWindow()
#region ColorTheme
- public void ChangeTheme(Control.ControlCollection container)
+ public void ChangeTheme (Control.ControlCollection container)
{
#region ApplyColorToAllControls
foreach (Control component in container)
@@ -108,7 +110,7 @@ public bool ShowBookmarkCommentColumn
#region Public methods
- public void SetColumnizer(ILogLineColumnizer columnizer)
+ public void SetColumnizer (ILogLineColumnizer columnizer)
{
PaintHelper.SetColumnizer(columnizer, bookmarkDataGridView);
@@ -133,7 +135,7 @@ public void SetColumnizer(ILogLineColumnizer columnizer)
///
/// Called from LogWindow after reloading and when double clicking a header divider.
///
- public void ResizeColumns()
+ public void ResizeColumns ()
{
// this.bookmarkDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells);
for (int i = 2; i < bookmarkDataGridView.ColumnCount; ++i)
@@ -142,7 +144,7 @@ public void ResizeColumns()
}
}
- public void UpdateView()
+ public void UpdateView ()
{
bookmarkDataGridView.RowCount = bookmarkData?.Bookmarks.Count ?? 0;
ResizeColumns();
@@ -153,7 +155,7 @@ public void UpdateView()
/// Called from LogWindow if the bookmark text was changed via popup window
///
///
- public void BookmarkTextChanged(Bookmark bookmark)
+ public void BookmarkTextChanged (Bookmark bookmark)
{
int rowIndex = bookmarkDataGridView.CurrentCellAddress.Y;
if (rowIndex == -1)
@@ -169,7 +171,7 @@ public void BookmarkTextChanged(Bookmark bookmark)
bookmarkDataGridView.Refresh();
}
- public void SelectBookmark(int lineNum)
+ public void SelectBookmark (int lineNum)
{
if (bookmarkData.IsBookmarkAtLine(lineNum))
{
@@ -184,7 +186,7 @@ public void SelectBookmark(int lineNum)
}
}
- public void SetBookmarkData(IBookmarkData bookmarkData)
+ public void SetBookmarkData (IBookmarkData bookmarkData)
{
this.bookmarkData = bookmarkData;
bookmarkDataGridView.RowCount = bookmarkData?.Bookmarks.Count ?? 0;
@@ -192,7 +194,8 @@ public void SetBookmarkData(IBookmarkData bookmarkData)
}
//TODO: BAD DESIGN! FIX!!!
- public void PreferencesChanged(Preferences newPreferences, bool isLoadTime, SettingsFlags flags, IConfigManager configManager) {
+ public void PreferencesChanged (Preferences newPreferences, bool isLoadTime, SettingsFlags flags, IConfigManager configManager)
+ {
if ((flags & SettingsFlags.GuiOrColors) == SettingsFlags.GuiOrColors)
{
SetFont(newPreferences.fontName, newPreferences.fontSize);
@@ -207,16 +210,16 @@ public void PreferencesChanged(Preferences newPreferences, bool isLoadTime, Sett
}
//TODO: BAD DESIGN! FIX!!!
- public void PreferencesChanged(Preferences newPreferences, bool isLoadTime, SettingsFlags flags)
+ public void PreferencesChanged (Preferences newPreferences, bool isLoadTime, SettingsFlags flags)
{
PreferencesChanged(newPreferences, isLoadTime, flags, null);
}
- public void SetCurrentFile(IFileViewContext ctx)
+ public void SetCurrentFile (IFileViewContext ctx)
{
if (ctx != null)
{
- _logger.Debug("Current file changed to {0}", ctx.LogView.FileName);
+ _logger.Debug($"Current file changed to {ctx.LogView.FileName}");
lock (paintLock)
{
logView = ctx.LogView;
@@ -234,7 +237,7 @@ public void SetCurrentFile(IFileViewContext ctx)
UpdateView();
}
- public void FileChanged()
+ public void FileChanged ()
{
// nothing to do
}
@@ -243,12 +246,12 @@ public void FileChanged()
#region Overrides
- protected override string GetPersistString()
+ protected override string GetPersistString ()
{
return WindowTypes.BookmarkWindow.ToString();
}
- protected override void OnPaint(PaintEventArgs e)
+ protected override void OnPaint (PaintEventArgs e)
{
if (!splitContainer1.Visible)
{
@@ -270,7 +273,7 @@ protected override void OnPaint(PaintEventArgs e)
#region Private Methods
- private void SetFont(string fontName, float fontSize)
+ private void SetFont (string fontName, float fontSize)
{
Font font = new(new FontFamily(fontName), fontSize);
bookmarkDataGridView.DefaultCellStyle.Font = font;
@@ -278,7 +281,7 @@ private void SetFont(string fontName, float fontSize)
bookmarkDataGridView.Refresh();
}
- private void CommentPainting(BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e)
+ private void CommentPainting (BufferedDataGridView gridView, int rowIndex, DataGridViewCellPaintingEventArgs e)
{
Color backColor = ColorMode.DockBackgroundColor;
@@ -309,7 +312,7 @@ private void CommentPainting(BufferedDataGridView gridView, int rowIndex, DataGr
e.PaintContent(e.CellBounds);
}
- private void DeleteSelectedBookmarks()
+ private void DeleteSelectedBookmarks ()
{
List lineNumList = [];
foreach (DataGridViewRow row in bookmarkDataGridView.SelectedRows)
@@ -323,7 +326,7 @@ private void DeleteSelectedBookmarks()
logView?.DeleteBookmarks(lineNumList);
}
- private static void InvalidateCurrentRow(BufferedDataGridView gridView)
+ private static void InvalidateCurrentRow (BufferedDataGridView gridView)
{
if (gridView.CurrentCellAddress.Y > -1)
{
@@ -331,7 +334,7 @@ private static void InvalidateCurrentRow(BufferedDataGridView gridView)
}
}
- private void CurrentRowChanged(int rowIndex)
+ private void CurrentRowChanged (int rowIndex)
{
if (rowIndex == -1)
{
@@ -349,12 +352,12 @@ private void CurrentRowChanged(int rowIndex)
}
}
- private void ShowCommentColumn(bool show)
+ private void ShowCommentColumn (bool show)
{
bookmarkDataGridView.Columns[1].Visible = show;
}
- private void HideIfNeeded()
+ private void HideIfNeeded ()
{
splitContainer1.Visible = bookmarkDataGridView.RowCount > 0;
}
@@ -363,7 +366,7 @@ private void HideIfNeeded()
#region Events handler
- private void boomarkDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
+ private void boomarkDataGridView_CellPainting (object sender, DataGridViewCellPaintingEventArgs e)
{
if (bookmarkData == null)
{
@@ -398,7 +401,7 @@ private void boomarkDataGridView_CellPainting(object sender, DataGridViewCellPai
}
}
- private void OnBoomarkDataGridViewCellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
+ private void OnBoomarkDataGridViewCellValueNeeded (object sender, DataGridViewCellValueEventArgs e)
{
if (bookmarkData == null)
{
@@ -425,7 +428,7 @@ private void OnBoomarkDataGridViewCellValueNeeded(object sender, DataGridViewCel
}
- private void boomarkDataGridView_MouseDoubleClick(object sender, MouseEventArgs e)
+ private void boomarkDataGridView_MouseDoubleClick (object sender, MouseEventArgs e)
{
// if (this.bookmarkDataGridView.CurrentRow != null)
// {
@@ -434,14 +437,14 @@ private void boomarkDataGridView_MouseDoubleClick(object sender, MouseEventArgs
// }
}
- private void boomarkDataGridView_ColumnDividerDoubleClick(object sender,
+ private void boomarkDataGridView_ColumnDividerDoubleClick (object sender,
DataGridViewColumnDividerDoubleClickEventArgs e)
{
e.Handled = true;
ResizeColumns();
}
- private void bookmarkGridView_KeyDown(object sender, KeyEventArgs e)
+ private void bookmarkGridView_KeyDown (object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
@@ -470,22 +473,22 @@ private void bookmarkGridView_KeyDown(object sender, KeyEventArgs e)
}
}
- private void bookmarkGridView_Enter(object sender, EventArgs e)
+ private void bookmarkGridView_Enter (object sender, EventArgs e)
{
InvalidateCurrentRow(bookmarkDataGridView);
}
- private void bookmarkGridView_Leave(object sender, EventArgs e)
+ private void bookmarkGridView_Leave (object sender, EventArgs e)
{
InvalidateCurrentRow(bookmarkDataGridView);
}
- private void deleteBookmarksToolStripMenuItem_Click(object sender, EventArgs e)
+ private void deleteBookmarksToolStripMenuItem_Click (object sender, EventArgs e)
{
DeleteSelectedBookmarks();
}
- private void bookmarkTextBox_TextChanged(object sender, EventArgs e)
+ private void bookmarkTextBox_TextChanged (object sender, EventArgs e)
{
if (!bookmarkTextBox.Enabled)
{
@@ -508,7 +511,7 @@ private void bookmarkTextBox_TextChanged(object sender, EventArgs e)
logView?.RefreshLogView();
}
- private void bookmarkDataGridView_SelectionChanged(object sender, EventArgs e)
+ private void bookmarkDataGridView_SelectionChanged (object sender, EventArgs e)
{
if (bookmarkDataGridView.SelectedRows.Count != 1
|| bookmarkDataGridView.SelectedRows[0].Index >= bookmarkData.Bookmarks.Count)
@@ -521,7 +524,7 @@ private void bookmarkDataGridView_SelectionChanged(object sender, EventArgs e)
}
}
- private void bookmarkDataGridView_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
+ private void bookmarkDataGridView_PreviewKeyDown (object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.Tab)
{
@@ -529,7 +532,7 @@ private void bookmarkDataGridView_PreviewKeyDown(object sender, PreviewKeyDownEv
}
}
- private void bookmarkDataGridView_CellToolTipTextNeeded(object sender,
+ private void bookmarkDataGridView_CellToolTipTextNeeded (object sender,
DataGridViewCellToolTipTextNeededEventArgs e)
{
if (e.ColumnIndex != 0 || e.RowIndex <= -1 || e.RowIndex >= bookmarkData.Bookmarks.Count)
@@ -545,7 +548,7 @@ private void bookmarkDataGridView_CellToolTipTextNeeded(object sender,
}
}
- private void bookmarkDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
+ private void bookmarkDataGridView_CellDoubleClick (object sender, DataGridViewCellEventArgs e)
{
// Toggle bookmark when double-clicking on the first column
if (e.ColumnIndex == 0 && e.RowIndex >= 0 && bookmarkDataGridView.CurrentRow != null)
@@ -597,7 +600,7 @@ private void bookmarkDataGridView_CellDoubleClick(object sender, DataGridViewCel
}
}
- private void removeCommentsToolStripMenuItem_Click(object sender, EventArgs e)
+ private void removeCommentsToolStripMenuItem_Click (object sender, EventArgs e)
{
if (
MessageBox.Show("Really remove bookmark comments for selected lines?", "LogExpert",
@@ -619,12 +622,12 @@ private void removeCommentsToolStripMenuItem_Click(object sender, EventArgs e)
}
}
- private void commentColumnCheckBox_CheckedChanged(object sender, EventArgs e)
+ private void commentColumnCheckBox_CheckedChanged (object sender, EventArgs e)
{
ShowCommentColumn(commentColumnCheckBox.Checked);
}
- private void BookmarkWindow_ClientSizeChanged(object sender, EventArgs e)
+ private void BookmarkWindow_ClientSizeChanged (object sender, EventArgs e)
{
if (Width > 0 && Height > 0)
{
@@ -653,17 +656,17 @@ private void BookmarkWindow_ClientSizeChanged(object sender, EventArgs e)
}
}
- private void bookmarkDataGridView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
+ private void bookmarkDataGridView_RowsAdded (object sender, DataGridViewRowsAddedEventArgs e)
{
HideIfNeeded();
}
- private void bookmarkDataGridView_RowsRemoved(object sender, DataGridViewRowsRemovedEventArgs e)
+ private void bookmarkDataGridView_RowsRemoved (object sender, DataGridViewRowsRemovedEventArgs e)
{
HideIfNeeded();
}
- private void BookmarkWindow_SizeChanged(object sender, EventArgs e)
+ private void BookmarkWindow_SizeChanged (object sender, EventArgs e)
{
// if (!this.splitContainer1.Visible)
// {
diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs
index e7093759..fba25456 100644
--- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs
+++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs
@@ -1,20 +1,20 @@
-using LogExpert.Core.Classes;
+using System.Reflection;
+using System.Text;
+
using LogExpert.Core.Config;
using LogExpert.Core.Entities;
using LogExpert.Core.Interface;
using LogExpert.Dialogs;
using LogExpert.UI.Extensions;
using LogExpert.UI.Extensions.Forms;
+
using NLog;
-using System.Reflection;
-using System.Text;
-using static LogExpert.UI.Controls.LogTabWindow.LogTabWindow;
namespace LogExpert.UI.Controls.LogTabWindow;
// Data shared over all LogTabWindow instances
//TODO: Can we get rid of this class?
-internal partial class LogTabWindow : Form, ILogTabWindow
+public partial class LogTabWindow : Form, ILogTabWindow
{
#region Fields
@@ -64,7 +64,7 @@ internal partial class LogTabWindow : Form, ILogTabWindow
#endregion
#region cTor
- public LogTabWindow(string[] fileNames, int instanceNumber, bool showInstanceNumbers, IConfigManager configManager)
+ public LogTabWindow (string[] fileNames, int instanceNumber, bool showInstanceNumbers, IConfigManager configManager)
{
AutoScaleDimensions = new SizeF(96F, 96F);
AutoScaleMode = AutoScaleMode.Dpi;
@@ -158,7 +158,7 @@ public LogTabWindow(string[] fileNames, int instanceNumber, bool showInstanceNum
#endregion
#region ColorTheme
- public void ChangeTheme(Control.ControlCollection container)
+ public void ChangeTheme (Control.ControlCollection container)
{
ColorMode.LoadColorMode(ConfigManager.Settings.Preferences.darkMode);
Win32.UseImmersiveDarkMode(Handle, ColorMode.DarkModeEnabled);
@@ -258,21 +258,21 @@ public void ChangeTheme(Control.ControlCollection container)
#region Delegates
- private delegate void AddFileTabsDelegate(string[] fileNames);
+ private delegate void AddFileTabsDelegate (string[] fileNames);
- private delegate void ExceptionFx();
+ private delegate void ExceptionFx ();
- private delegate void FileNotFoundDelegate(LogWindow.LogWindow logWin);
+ private delegate void FileNotFoundDelegate (LogWindow.LogWindow logWin);
- private delegate void FileRespawnedDelegate(LogWindow.LogWindow logWin);
+ private delegate void FileRespawnedDelegate (LogWindow.LogWindow logWin);
- public delegate void HighlightSettingsChangedEventHandler(object sender, EventArgs e);
+ public delegate void HighlightSettingsChangedEventHandler (object sender, EventArgs e);
- private delegate void LoadMultiFilesDelegate(string[] fileName, EncodingOptions encodingOptions);
+ private delegate void LoadMultiFilesDelegate (string[] fileName, EncodingOptions encodingOptions);
- private delegate void SetColumnizerFx(ILogLineColumnizer columnizer);
+ private delegate void SetColumnizerFx (ILogLineColumnizer columnizer);
- private delegate void SetTabIconDelegate(LogWindow.LogWindow logWindow, Icon icon);
+ private delegate void SetTabIconDelegate (LogWindow.LogWindow logWindow, Icon icon);
#endregion
@@ -308,7 +308,7 @@ public LogWindow.LogWindow CurrentLogWindow
#region Internals
- internal HighlightGroup FindHighlightGroup(string groupName)
+ internal HighlightGroup FindHighlightGroup (string groupName)
{
lock (HighlightGroupList)
{
@@ -340,24 +340,4 @@ private class LogWindowData
#endregion
}
-}
-
-public class StaticLogTabWindowData
-{
- #region Properties
-
- public ILogTabWindow CurrentLockedMainWindow { get; set; }
-
- #endregion
-}
-
-public abstract class AbstractLogTabWindow()
-{
- public static StaticLogTabWindowData StaticData { get; set; } = new StaticLogTabWindowData();
-
- public static ILogTabWindow Create(string[] fileNames, int instanceNumber, bool showInstanceNumbers, IConfigManager configManager)
- {
- return new LogTabWindow(fileNames, instanceNumber, showInstanceNumbers, configManager);
- }
-
-}
+}
\ No newline at end of file
diff --git a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs
index 5da464b5..b515cdcb 100644
--- a/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs
+++ b/src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowEventHandlers.cs
@@ -1,13 +1,16 @@
-using LogExpert.Core.Classes;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Text;
+
+using LogExpert.Core.Classes;
using LogExpert.Core.Classes.Persister;
using LogExpert.Core.Config;
using LogExpert.Core.Entities;
using LogExpert.Core.EventArguments;
using LogExpert.Dialogs;
using LogExpert.UI.Dialogs;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Text;
+using LogExpert.UI.Dialogs.LogTabWindow;
+
using WeifenLuo.WinFormsUI.Docking;
namespace LogExpert.UI.Controls.LogTabWindow;
@@ -15,12 +18,12 @@ partial class LogTabWindow
{
#region Events handler
- private void OnBookmarkWindowVisibleChanged(object sender, EventArgs e)
+ private void OnBookmarkWindowVisibleChanged (object sender, EventArgs e)
{
_firstBookmarkWindowShow = false;
}
- private void OnLogTabWindowLoad(object sender, EventArgs e)
+ private void OnLogTabWindowLoad (object sender, EventArgs e)
{
ApplySettings(ConfigManager.Settings, SettingsFlags.All);
if (ConfigManager.Settings.isMaximized)
@@ -64,7 +67,7 @@ private void OnLogTabWindowLoad(object sender, EventArgs e)
#endif
}
- private void OnLogTabWindowClosing(object sender, CancelEventArgs e)
+ private void OnLogTabWindowClosing (object sender, CancelEventArgs e)
{
try
{
@@ -105,7 +108,7 @@ private void OnLogTabWindowClosing(object sender, CancelEventArgs e)
}
}
- private void OnStripMouseUp(object sender, MouseEventArgs e)
+ private void OnStripMouseUp (object sender, MouseEventArgs e)
{
if (sender is ToolStripDropDown dropDown)
{
@@ -113,7 +116,7 @@ private void OnStripMouseUp(object sender, MouseEventArgs e)
}
}
- private void OnHistoryItemClicked(object sender, ToolStripItemClickedEventArgs e)
+ private void OnHistoryItemClicked (object sender, ToolStripItemClickedEventArgs e)
{
if (string.IsNullOrEmpty(e.ClickedItem.Text) == false)
{
@@ -121,7 +124,7 @@ private void OnHistoryItemClicked(object sender, ToolStripItemClickedEventArgs e
}
}
- private void OnLogWindowDisposed(object sender, EventArgs e)
+ private void OnLogWindowDisposed (object sender, EventArgs e)
{
LogWindow.LogWindow logWindow = sender as LogWindow.LogWindow;
@@ -135,12 +138,12 @@ private void OnLogWindowDisposed(object sender, EventArgs e)
logWindow.Tag = null;
}
- private void OnExitToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnExitToolStripMenuItemClick (object sender, EventArgs e)
{
Close();
}
- private void OnSelectFilterToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnSelectFilterToolStripMenuItemClick (object sender, EventArgs e)
{
if (CurrentLogWindow == null)
{
@@ -204,7 +207,7 @@ private void OnSelectFilterToolStripMenuItemClick(object sender, EventArgs e)
}
}
- private void OnGoToLineToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnGoToLineToolStripMenuItemClick (object sender, EventArgs e)
{
if (CurrentLogWindow == null)
{
@@ -223,22 +226,22 @@ private void OnGoToLineToolStripMenuItemClick(object sender, EventArgs e)
}
}
- private void OnHighlightingToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnHighlightingToolStripMenuItemClick (object sender, EventArgs e)
{
ShowHighlightSettingsDialog();
}
- private void OnSearchToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnSearchToolStripMenuItemClick (object sender, EventArgs e)
{
OpenSearchDialog();
}
- private void OnOpenToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnOpenToolStripMenuItemClick (object sender, EventArgs e)
{
OpenFileDialog();
}
- private void OnLogTabWindowDragEnter(object sender, DragEventArgs e)
+ private void OnLogTabWindowDragEnter (object sender, DragEventArgs e)
{
#if DEBUG
string[] formats = e.Data.GetFormats();
@@ -253,7 +256,7 @@ private void OnLogTabWindowDragEnter(object sender, DragEventArgs e)
#endif
}
- private void OnLogWindowDragOver(object sender, DragEventArgs e)
+ private void OnLogWindowDragOver (object sender, DragEventArgs e)
{
if (!e.Data.GetDataPresent(DataFormats.FileDrop))
{
@@ -265,7 +268,7 @@ private void OnLogWindowDragOver(object sender, DragEventArgs e)
}
}
- private void OnLogWindowDragDrop(object sender, DragEventArgs e)
+ private void OnLogWindowDragDrop (object sender, DragEventArgs e)
{
#if DEBUG
string[] formats = e.Data.GetFormats();
@@ -290,7 +293,7 @@ private void OnLogWindowDragDrop(object sender, DragEventArgs e)
}
}
- private void OnTimeShiftToolStripMenuItemCheckStateChanged(object sender, EventArgs e)
+ private void OnTimeShiftToolStripMenuItemCheckStateChanged (object sender, EventArgs e)
{
if (!_skipEvents && CurrentLogWindow != null)
{
@@ -301,65 +304,65 @@ private void OnTimeShiftToolStripMenuItemCheckStateChanged(object sender, EventA
}
}
- private void OnAboutToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnAboutToolStripMenuItemClick (object sender, EventArgs e)
{
AboutBox aboutBox = new();
aboutBox.TopMost = TopMost;
aboutBox.ShowDialog();
}
- private void OnFilterToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnFilterToolStripMenuItemClick (object sender, EventArgs e)
{
CurrentLogWindow?.ToggleFilterPanel();
}
- private void OnMultiFileToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnMultiFileToolStripMenuItemClick (object sender, EventArgs e)
{
ToggleMultiFile();
fileToolStripMenuItem.HideDropDown();
}
- private void OnGuiStateUpdate(object sender, GuiStateArgs e)
+ private void OnGuiStateUpdate (object sender, GuiStateArgs e)
{
BeginInvoke(GuiStateUpdateWorker, e);
}
- private void OnColumnizerChanged(object sender, ColumnizerEventArgs e)
+ private void OnColumnizerChanged (object sender, ColumnizerEventArgs e)
{
_bookmarkWindow?.SetColumnizer(e.Columnizer);
}
- private void OnBookmarkAdded(object sender, EventArgs e)
+ private void OnBookmarkAdded (object sender, EventArgs e)
{
_bookmarkWindow.UpdateView();
}
- private void OnBookmarkTextChanged(object sender, BookmarkEventArgs e)
+ private void OnBookmarkTextChanged (object sender, BookmarkEventArgs e)
{
_bookmarkWindow.BookmarkTextChanged(e.Bookmark);
}
- private void OnBookmarkRemoved(object sender, EventArgs e)
+ private void OnBookmarkRemoved (object sender, EventArgs e)
{
_bookmarkWindow.UpdateView();
}
- private void OnProgressBarUpdate(object sender, ProgressEventArgs e)
+ private void OnProgressBarUpdate (object sender, ProgressEventArgs e)
{
Invoke(ProgressBarUpdateWorker, e);
}
- private void OnStatusLineEvent(object sender, StatusLineEventArgs e)
+ private void OnStatusLineEvent (object sender, StatusLineEventArgs e)
{
StatusLineEventWorker(e);
}
- private void OnFollowTailCheckBoxClick(object sender, EventArgs e)
+ private void OnFollowTailCheckBoxClick (object sender, EventArgs e)
{
CurrentLogWindow?.FollowTailChanged(checkBoxFollowTail.Checked, false);
}
- private void OnLogTabWindowKeyDown(object sender, KeyEventArgs e)
+ private void OnLogTabWindowKeyDown (object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.W && e.Control)
{
@@ -375,22 +378,22 @@ private void OnLogTabWindowKeyDown(object sender, KeyEventArgs e)
}
}
- private void OnCloseFileToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnCloseFileToolStripMenuItemClick (object sender, EventArgs e)
{
CurrentLogWindow?.Close();
}
- private void OnCellSelectModeToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnCellSelectModeToolStripMenuItemClick (object sender, EventArgs e)
{
CurrentLogWindow?.SetCellSelectionMode(cellSelectModeToolStripMenuItem.Checked);
}
- private void OnCopyMarkedLinesIntoNewTabToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnCopyMarkedLinesIntoNewTabToolStripMenuItemClick (object sender, EventArgs e)
{
CurrentLogWindow?.CopyMarkedLinesToTab();
}
- private void OnTimeShiftMenuTextBoxKeyDown(object sender, KeyEventArgs e)
+ private void OnTimeShiftMenuTextBoxKeyDown (object sender, KeyEventArgs e)
{
if (CurrentLogWindow == null)
{
@@ -404,12 +407,12 @@ private void OnTimeShiftMenuTextBoxKeyDown(object sender, KeyEventArgs e)
}
}
- private void OnAlwaysOnTopToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnAlwaysOnTopToolStripMenuItemClick (object sender, EventArgs e)
{
TopMost = alwaysOnTopToolStripMenuItem.Checked;
}
- private void OnFileSizeChanged(object sender, LogEventArgs e)
+ private void OnFileSizeChanged (object sender, LogEventArgs e)
{
if (sender.GetType().IsAssignableFrom(typeof(LogWindow.LogWindow)))
{
@@ -443,17 +446,17 @@ private void OnFileSizeChanged(object sender, LogEventArgs e)
}
}
- private void OnLogWindowFileNotFound(object sender, EventArgs e)
+ private void OnLogWindowFileNotFound (object sender, EventArgs e)
{
Invoke(new FileNotFoundDelegate(FileNotFound), sender);
}
- private void OnLogWindowFileRespawned(object sender, EventArgs e)
+ private void OnLogWindowFileRespawned (object sender, EventArgs e)
{
Invoke(new FileRespawnedDelegate(FileRespawned), sender);
}
- private void OnLogWindowFilterListChanged(object sender, FilterListChangedEventArgs e)
+ private void OnLogWindowFilterListChanged (object sender, FilterListChangedEventArgs e)
{
lock (_logWindowList)
{
@@ -468,14 +471,14 @@ private void OnLogWindowFilterListChanged(object sender, FilterListChangedEventA
ConfigManager.Save(SettingsFlags.FilterList);
}
- private void OnLogWindowCurrentHighlightGroupChanged(object sender, CurrentHighlightGroupChangedEventArgs e)
+ private void OnLogWindowCurrentHighlightGroupChanged (object sender, CurrentHighlightGroupChangedEventArgs e)
{
OnHighlightSettingsChanged();
ConfigManager.Settings.Preferences.HighlightGroupList = HighlightGroupList;
ConfigManager.Save(SettingsFlags.HighlightSettings);
}
- private void OnTailFollowed(object sender, EventArgs e)
+ private void OnTailFollowed (object sender, EventArgs e)
{
if (dockPanel.ActiveContent == null)
{
@@ -493,7 +496,7 @@ private void OnTailFollowed(object sender, EventArgs e)
}
}
- private void OnLogWindowSyncModeChanged(object sender, SyncModeEventArgs e)
+ private void OnLogWindowSyncModeChanged (object sender, SyncModeEventArgs e)
{
if (!Disposing)
{
@@ -508,47 +511,47 @@ private void OnLogWindowSyncModeChanged(object sender, SyncModeEventArgs e)
}
}
- private void OnToggleBookmarkToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnToggleBookmarkToolStripMenuItemClick (object sender, EventArgs e)
{
CurrentLogWindow?.ToggleBookmark();
}
- private void OnJumpToNextToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnJumpToNextToolStripMenuItemClick (object sender, EventArgs e)
{
CurrentLogWindow?.JumpNextBookmark();
}
- private void OnJumpToPrevToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnJumpToPrevToolStripMenuItemClick (object sender, EventArgs e)
{
CurrentLogWindow?.JumpPrevBookmark();
}
- private void OnASCIIToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnASCIIToolStripMenuItemClick (object sender, EventArgs e)
{
CurrentLogWindow?.ChangeEncoding(Encoding.ASCII);
}
- private void OnANSIToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnANSIToolStripMenuItemClick (object sender, EventArgs e)
{
CurrentLogWindow?.ChangeEncoding(Encoding.Default);
}
- private void OnUTF8ToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnUTF8ToolStripMenuItemClick (object sender, EventArgs e)
{
CurrentLogWindow?.ChangeEncoding(new UTF8Encoding(false));
}
- private void OnUTF16ToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnUTF16ToolStripMenuItemClick (object sender, EventArgs e)
{
CurrentLogWindow?.ChangeEncoding(Encoding.Unicode);
}
- private void OnISO88591ToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnISO88591ToolStripMenuItemClick (object sender, EventArgs e)
{
CurrentLogWindow?.ChangeEncoding(Encoding.GetEncoding("iso-8859-1"));
}
- private void OnReloadToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnReloadToolStripMenuItemClick (object sender, EventArgs e)
{
if (CurrentLogWindow != null)
{
@@ -559,12 +562,12 @@ private void OnReloadToolStripMenuItemClick(object sender, EventArgs e)
}
}
- private void OnSettingsToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnSettingsToolStripMenuItemClick (object sender, EventArgs e)
{
OpenSettings(0);
}
- private void OnDateTimeDragControlValueDragged(object sender, EventArgs e)
+ private void OnDateTimeDragControlValueDragged (object sender, EventArgs e)
{
if (CurrentLogWindow != null)
{
@@ -572,22 +575,22 @@ private void OnDateTimeDragControlValueDragged(object sender, EventArgs e)
}
}
- private void OnDateTimeDragControlValueChanged(object sender, EventArgs e)
+ private void OnDateTimeDragControlValueChanged (object sender, EventArgs e)
{
CurrentLogWindow?.ScrollToTimestamp(dragControlDateTime.DateTime, true, true);
}
- private void OnLogTabWindowDeactivate(object sender, EventArgs e)
+ private void OnLogTabWindowDeactivate (object sender, EventArgs e)
{
CurrentLogWindow?.AppFocusLost();
}
- private void OnLogTabWindowActivated(object sender, EventArgs e)
+ private void OnLogTabWindowActivated (object sender, EventArgs e)
{
CurrentLogWindow?.AppFocusGained();
}
- private void OnShowBookmarkListToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnShowBookmarkListToolStripMenuItemClick (object sender, EventArgs e)
{
if (_bookmarkWindow.Visible)
{
@@ -606,42 +609,42 @@ private void OnShowBookmarkListToolStripMenuItemClick(object sender, EventArgs e
}
}
- private void OnToolStripButtonOpenClick(object sender, EventArgs e)
+ private void OnToolStripButtonOpenClick (object sender, EventArgs e)
{
OpenFileDialog();
}
- private void OnToolStripButtonSearchClick(object sender, EventArgs e)
+ private void OnToolStripButtonSearchClick (object sender, EventArgs e)
{
OpenSearchDialog();
}
- private void OnToolStripButtonFilterClick(object sender, EventArgs e)
+ private void OnToolStripButtonFilterClick (object sender, EventArgs e)
{
CurrentLogWindow?.ToggleFilterPanel();
}
- private void OnToolStripButtonBookmarkClick(object sender, EventArgs e)
+ private void OnToolStripButtonBookmarkClick (object sender, EventArgs e)
{
CurrentLogWindow?.ToggleBookmark();
}
- private void OnToolStripButtonUpClick(object sender, EventArgs e)
+ private void OnToolStripButtonUpClick (object sender, EventArgs e)
{
CurrentLogWindow?.JumpPrevBookmark();
}
- private void OnToolStripButtonDownClick(object sender, EventArgs e)
+ private void OnToolStripButtonDownClick (object sender, EventArgs e)
{
CurrentLogWindow?.JumpNextBookmark();
}
- private void OnShowHelpToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnShowHelpToolStripMenuItemClick (object sender, EventArgs e)
{
Help.ShowHelp(this, "LogExpert.chm");
}
- private void OnHideLineColumnToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnHideLineColumnToolStripMenuItemClick (object sender, EventArgs e)
{
ConfigManager.Settings.hideLineColumn = hideLineColumnToolStripMenuItem.Checked;
lock (_logWindowList)
@@ -658,12 +661,12 @@ private void OnHideLineColumnToolStripMenuItemClick(object sender, EventArgs e)
// Tab context menu stuff
// ==================================================================
- private void OnCloseThisTabToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnCloseThisTabToolStripMenuItemClick (object sender, EventArgs e)
{
(dockPanel.ActiveContent as LogWindow.LogWindow).Close();
}
- private void OnCloseOtherTabsToolStripMenuItemClick(object sender, EventArgs e)
+ private void OnCloseOtherTabsToolStripMenuItemClick (object sender, EventArgs e)
{
IList