Skip to content

Commit 7c86104

Browse files
author
BRUNER Patrick
committed
fixes #520
1 parent 090c70b commit 7c86104

10 files changed

Lines changed: 58 additions & 44 deletions

File tree

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
51
namespace ColumnizerLib;
62

73
/// <summary>
8-
/// Implement this interface to execute a self defined action when LogExpert detects a
4+
/// Implement this interface to execute a self defined action when LogExpert detects a
95
/// keyword on incomig log file content.
106
/// These kind of plugins can be used in the "Highlight and Action Triggers" dialog.
117
/// </summary>
@@ -21,30 +17,30 @@ public interface IKeywordAction
2117
/// <param name="keyword">The keyword which triggered the call.</param>
2218
/// <param name="param">The parameter configured for the plugin launch (in the Highlight dialog).</param>
2319
/// <param name="callback">A callback which can be used by the plugin.</param>
24-
/// <param name="columnizer">The current columnizer. Can be used to obtain timestamps
20+
/// <param name="columnizer">The current columnizer. Can be used to obtain timestamps
2521
/// (if supported by Columnizer) or to split the log line into fields.</param>
2622
/// <remarks>
27-
/// This method is called in a background thread from the process' thread pool (using BeginInvoke()).
23+
/// This method is called in a background thread from the process' thread pool (using BeginInvoke()).
2824
/// So you cannot rely on state information retrieved by the given callback. E.g. the line count
2925
/// may change during the execution of the method. The only exception from this rule is the current line number
3026
/// retrieved from the callback. This is of course the line number of the line that has triggered
3127
/// the keyword match.
3228
/// </remarks>
33-
void Execute(string keyword, string param, ILogExpertCallback callback, ILogLineMemoryColumnizer columnizer);
29+
void Execute (string keyword, string param, ILogExpertCallbackMemory callback, ILogLineMemoryColumnizer columnizer);
3430

3531
/// <summary>
36-
/// Return the name of your plugin here. The returned name is used for displaying the plugin list
32+
/// Return the name of your plugin here. The returned name is used for displaying the plugin list
3733
/// in the settings.
3834
/// </summary>
3935
/// <returns>The name of the plugin.</returns>
40-
string GetName();
36+
string GetName ();
4137

4238
/// <summary>
4339
/// Return a description of your plugin here. E.g. a short explanation of parameters. The descriptions
4440
/// will be displayed in the plugin chooser dialog which is used by the Highlight settings.
4541
/// </summary>
4642
/// <returns>The description of the plugin.</returns>
47-
string GetDescription();
43+
string GetDescription ();
4844

4945
#endregion
5046
}

src/CsvColumnizer/CsvColumnizer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public void Selected (ILogLineMemoryColumnizerCallback callback)
187187
_columnList.Clear();
188188
var line = _config.HasFieldNames
189189
? _firstLine
190-
: callback.GetLogLine(0);
190+
: callback.GetLogLineMemory(0);
191191

192192
if (line != null)
193193
{

src/DefaultPlugins/ProcessLauncher.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using System.Diagnostics;
32

43
using ColumnizerLib;
@@ -15,9 +14,9 @@ internal class ProcessLauncher : IKeywordAction
1514

1615
#region IKeywordAction Member
1716

18-
private readonly object _callbackLock = new();
17+
private readonly Lock _callbackLock = new();
1918

20-
public void Execute (string keyword, string param, ILogExpertCallback callback, ILogLineMemoryColumnizer columnizer)
19+
public void Execute (string keyword, string param, ILogExpertCallbackMemory callback, ILogLineMemoryColumnizer columnizer)
2120
{
2221
var start = 0;
2322
int end;
@@ -46,16 +45,16 @@ public void Execute (string keyword, string param, ILogExpertCallback callback,
4645
parameters = parameters.Replace("%K", keyword, StringComparison.Ordinal);
4746

4847
var lineNumber = callback.LineNum; //Line Numbers start at 0, but are displayed (+1)
49-
var logline = callback.GetLogLine(lineNumber).FullLine;
50-
parameters = parameters.Replace("%L", string.Empty + lineNumber, System.StringComparison.Ordinal);
48+
var logline = callback.GetLogLineMemory(lineNumber).FullLine;
49+
parameters = parameters.Replace("%L", string.Empty + lineNumber, StringComparison.Ordinal);
5150
parameters = parameters.Replace("%T", callback.GetTabTitle(), StringComparison.Ordinal);
52-
parameters = parameters.Replace("%C", logline, StringComparison.Ordinal);
51+
parameters = parameters.Replace("%C", logline.ToString(), StringComparison.Ordinal);
5352

5453
Process explorer = new();
5554
explorer.StartInfo.FileName = procName;
5655
explorer.StartInfo.Arguments = parameters;
5756
explorer.StartInfo.UseShellExecute = false;
58-
explorer.Start();
57+
_ = explorer.Start();
5958
}
6059
}
6160

src/LogExpert.Core/Classes/Filter/FilterPipe.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using ColumnizerLib;
55

66
using LogExpert.Core.Interface;
7+
78
using NLog;
89

910
namespace LogExpert.Core.Classes.Filter;
@@ -23,7 +24,7 @@ public class FilterPipe : IDisposable
2324

2425
#region cTor
2526

26-
public FilterPipe(FilterParams filterParams, ILogWindow logWindow)
27+
public FilterPipe (FilterParams filterParams, ILogWindow logWindow)
2728
{
2829
FilterParams = filterParams;
2930
LogWindow = logWindow;
@@ -68,15 +69,12 @@ public void OpenFile ()
6869

6970
public void CloseFile ()
7071
{
71-
if (_writer != null)
72-
{
73-
_writer.Close();
74-
_writer = null;
75-
}
72+
_writer?.Close();
73+
_writer = null;
7674
}
7775

7876
//TOOD: check if the callers are checking for null before calling
79-
public bool WriteToPipe (ILogLine textLine, int orgLineNum)
77+
public bool WriteToPipe (ILogLineMemory textLine, int orgLineNum)
8078
{
8179
ArgumentNullException.ThrowIfNull(textLine, nameof(textLine));
8280

@@ -88,7 +86,7 @@ public bool WriteToPipe (ILogLine textLine, int orgLineNum)
8886
{
8987
try
9088
{
91-
_writer.WriteLine(textLine.FullLine);
89+
_writer.WriteLine(textLine.FullLine.ToString());
9290
_lineMappingList.Add(orgLineNum);
9391
return true;
9492
}

src/LogExpert.Core/Classes/Log/LogfileReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,15 +1277,15 @@ private void ReadToBufferList (ILogFileInfo logFileInfo, long filePos, int start
12771277
}
12781278
}
12791279

1280-
AcquireDisposeReaderLock();
1280+
AcquireDisposeLockUpgradableReadLock();
12811281
if (logBuffer.IsDisposed)
12821282
{
12831283
UpgradeDisposeLockToWriterLock();
12841284
ReReadBuffer(logBuffer);
12851285
DowngradeDisposeLockFromWriterLock();
12861286
}
12871287

1288-
ReleaseDisposeReaderLock();
1288+
ReleaseDisposeUpgradeableReadLock();
12891289
}
12901290
}
12911291
finally

src/LogExpert.Core/EventArguments/ContextMenuPluginEventArgs.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace LogExpert.Core.EventArguments;
44

5-
public class ContextMenuPluginEventArgs(IContextMenuEntry entry, IList<int> logLines, ILogLineMemoryColumnizer columnizer,
6-
ILogExpertCallback callback) : System.EventArgs
5+
public class ContextMenuPluginEventArgs (IContextMenuEntry entry, IList<int> logLines, ILogLineMemoryColumnizer columnizer,
6+
ILogExpertCallbackMemory callback) : EventArgs
77
{
88

99
#region Properties
@@ -14,7 +14,7 @@ public class ContextMenuPluginEventArgs(IContextMenuEntry entry, IList<int> logL
1414

1515
public ILogLineMemoryColumnizer Columnizer { get; } = columnizer;
1616

17-
public ILogExpertCallback Callback { get; } = callback;
17+
public ILogExpertCallbackMemory Callback { get; } = callback;
1818

1919
#endregion
2020
}

src/LogExpert.Core/Interface/ILogWindow.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,21 @@ public interface ILogWindow
199199
/// </remarks>
200200
void WritePipeTab (IList<LineEntry> lineEntryList, string title);
201201

202+
/// <summary>
203+
/// Creates a new tab containing the specified list of log line entries.
204+
/// </summary>
205+
/// <param name="lineEntryList">
206+
/// A list of <see cref="LineEntryMemory"/> objects containing the lines and their
207+
/// original line numbers to display in the new tab.
208+
/// </param>
209+
/// <param name="title">The title to display on the tab.</param>
210+
/// <remarks>
211+
/// This method is used to pipe filtered or selected content into a new tab
212+
/// without creating a physical file. The new tab maintains references to the
213+
/// original line numbers for context.
214+
/// </remarks>
215+
void WritePipeTab (IList<LineEntryMemory> lineEntryList, string title);
216+
202217
/// <summary>
203218
/// Activates this log window and brings it to the foreground.
204219
/// </summary>

src/LogExpert.Tests/Services/LedIndicatorServiceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public void CurrentTailColor_AfterDispose_ThrowsObjectDisposedException ()
282282
_service.Dispose();
283283

284284
// Act & Assert
285-
Assert.Throws<ObjectDisposedException>(() => _ = _service.CurrentTailColor);
285+
_ = Assert.Throws<ObjectDisposedException>(() => _ = _service.CurrentTailColor);
286286
}
287287

288288
[Test]

src/LogExpert.UI/Controls/LogWindow/LogExpertCallback.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace LogExpert.UI.Controls.LogWindow;
66

7-
internal class LogExpertCallback (LogWindow logWindow) : ColumnizerCallback(logWindow), ILogExpertCallback
7+
internal class LogExpertCallback (LogWindow logWindow) : ColumnizerCallback(logWindow), ILogExpertCallbackMemory
88
{
99
#region Public methods
1010

@@ -13,7 +13,7 @@ public void AddTempFileTab (string fileName, string title)
1313
logWindow.AddTempFileTab(fileName, title);
1414
}
1515

16-
public void AddPipedTab (IList<LineEntry> lineEntryList, string title)
16+
public void AddPipedTab (IList<LineEntryMemory> lineEntryList, string title)
1717
{
1818
logWindow.WritePipeTab(lineEntryList, title);
1919
}

src/LogExpert.UI/Controls/LogWindow/LogWindow.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ private void OnButtonSizeChanged (object sender, EventArgs e)
698698

699699
private delegate void PatternStatisticFx (PatternArgs patternArgs);
700700

701-
private delegate void ActionPluginExecuteFx (string keyword, string param, ILogExpertCallback callback, ILogLineMemoryColumnizer columnizer);
701+
private delegate void ActionPluginExecuteFx (string keyword, string param, ILogExpertCallbackMemory callback, ILogLineMemoryColumnizer columnizer);
702702

703703
private delegate void PositionAfterReloadFx (ReloadMemento reloadMemento);
704704

@@ -735,11 +735,17 @@ void ILogWindow.AddTempFileTab (string fileName, string title)
735735
}
736736

737737
[SupportedOSPlatform("windows")]
738-
void ILogWindow.WritePipeTab (IList<LineEntry> lineEntryList, string title)
738+
void ILogWindow.WritePipeTab (IList<LineEntryMemory> lineEntryList, string title)
739739
{
740740
WritePipeTab(lineEntryList, title);
741741
}
742742

743+
[SupportedOSPlatform("windows")]
744+
void ILogWindow.WritePipeTab (IList<LineEntry> lineEntryList, string title)
745+
{
746+
//WritePipeTab(lineEntryList, title);
747+
}
748+
743749
#region Event Handlers
744750

745751
[SupportedOSPlatform("windows")]
@@ -1472,7 +1478,7 @@ private void OnDataGridContextMenuStripOpening (object sender, CancelEventArgs e
14721478
foreach (var entry in PluginRegistry.PluginRegistry.Instance.RegisteredContextMenuPlugins)
14731479
{
14741480
LogExpertCallback callback = new(this);
1475-
var menuText = entry.GetMenuText(lines.Count, CurrentColumnizer, callback.GetLogLine(lines[0]));
1481+
var menuText = entry.GetMenuText(lines.Count, CurrentColumnizer, callback.GetLogLineMemory(lines[0]));
14761482

14771483
if (menuText != null)
14781484
{
@@ -5014,11 +5020,11 @@ private void WritePipeToTab (FilterPipe pipe, List<int> lineNumberList, string n
50145020
break;
50155021
}
50165022

5017-
var line = _logFileReader.GetLogLine(i);
5018-
if (CurrentColumnizer is ILogLineXmlColumnizer)
5023+
var line = _logFileReader.GetLogLineMemory(i);
5024+
if (CurrentColumnizer is ILogLineMemoryXmlColumnizer)
50195025
{
50205026
callback.LineNum = i;
5021-
line = (CurrentColumnizer as ILogLineXmlColumnizer).GetLineTextForClipboard(line, callback);
5027+
line = (CurrentColumnizer as ILogLineMemoryXmlColumnizer).GetLineTextForClipboard(line, callback);
50225028
}
50235029

50245030
_ = pipe.WriteToPipe(line, i);
@@ -5041,7 +5047,7 @@ private void WriteFilterToTabFinished (FilterPipe pipe, string name, Persistence
50415047
{
50425048
var title = name;
50435049
ILogLineMemoryColumnizer preProcessColumnizer = null;
5044-
if (CurrentColumnizer is not ILogLineXmlColumnizer)
5050+
if (CurrentColumnizer is not ILogLineMemoryXmlColumnizer)
50455051
{
50465052
preProcessColumnizer = CurrentColumnizer;
50475053
}
@@ -5070,7 +5076,7 @@ private void WriteFilterToTabFinished (FilterPipe pipe, string name, Persistence
50705076
/// <param name="lineEntryList"></param>
50715077
/// <param name="title"></param>
50725078
[SupportedOSPlatform("windows")]
5073-
internal void WritePipeTab (IList<LineEntry> lineEntryList, string title)
5079+
internal void WritePipeTab (IList<LineEntryMemory> lineEntryList, string title)
50745080
{
50755081
FilterPipe pipe = new(new FilterParams(), this)
50765082
{
@@ -5145,7 +5151,7 @@ private void ProcessFilterPipes (int lineNum)
51455151
pipe.LastLinesHistoryList.RemoveAt(0);
51465152
}
51475153

5148-
var textLine = _logFileReader.GetLogLine(line);
5154+
var textLine = _logFileReader.GetLogLineMemory(line);
51495155
var fileOk = pipe.WriteToPipe(textLine, line);
51505156
if (!fileOk)
51515157
{

0 commit comments

Comments
 (0)