Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions src/ColumnizerLib/IKeywordAction.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace ColumnizerLib;

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

/// <summary>
/// Return the name of your plugin here. The returned name is used for displaying the plugin list
/// Return the name of your plugin here. The returned name is used for displaying the plugin list
/// in the settings.
/// </summary>
/// <returns>The name of the plugin.</returns>
string GetName();
string GetName ();

/// <summary>
/// Return a description of your plugin here. E.g. a short explanation of parameters. The descriptions
/// will be displayed in the plugin chooser dialog which is used by the Highlight settings.
/// </summary>
/// <returns>The description of the plugin.</returns>
string GetDescription();
string GetDescription ();

#endregion
}
2 changes: 1 addition & 1 deletion src/CsvColumnizer/CsvColumnizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public void Selected (ILogLineMemoryColumnizerCallback callback)
_columnList.Clear();
var line = _config.HasFieldNames
? _firstLine
: callback.GetLogLine(0);
: callback.GetLogLineMemory(0);

if (line != null)
{
Expand Down
13 changes: 6 additions & 7 deletions src/DefaultPlugins/ProcessLauncher.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Diagnostics;

using ColumnizerLib;
Expand All @@ -15,9 +14,9 @@ internal class ProcessLauncher : IKeywordAction

#region IKeywordAction Member

private readonly object _callbackLock = new();
private readonly Lock _callbackLock = new();

public void Execute (string keyword, string param, ILogExpertCallback callback, ILogLineMemoryColumnizer columnizer)
public void Execute (string keyword, string param, ILogExpertCallbackMemory callback, ILogLineMemoryColumnizer columnizer)
{
var start = 0;
int end;
Expand Down Expand Up @@ -46,16 +45,16 @@ public void Execute (string keyword, string param, ILogExpertCallback callback,
parameters = parameters.Replace("%K", keyword, StringComparison.Ordinal);

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

Process explorer = new();
explorer.StartInfo.FileName = procName;
explorer.StartInfo.Arguments = parameters;
explorer.StartInfo.UseShellExecute = false;
explorer.Start();
_ = explorer.Start();
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/FlashIconHighlighter/FlashIconHighlighter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<OutputPath>$(SolutionDir)..\bin\$(Configuration)\plugins</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyTitle>FlashIconHighlighter</AssemblyTitle>
<RootNamespace>FlashIconHighlighter</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Vanara.PInvoke.User32" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ColumnizerLib\ColumnizerLib.csproj" />
</ItemGroup>
Expand Down
18 changes: 11 additions & 7 deletions src/FlashIconHighlighter/FlashIconPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Windows.Forms;

using ColumnizerLib;

using static Vanara.PInvoke.User32;

[assembly: SupportedOSPlatform("windows")]
namespace FlashIconHighlighter;

Expand All @@ -18,29 +18,33 @@ internal class FlashIconPlugin : IKeywordAction

#region IKeywordAction Member

public void Execute (string keyword, string param, ILogExpertCallback callback, ILogLineMemoryColumnizer columnizer)
public void Execute (string keyword, string param, ILogExpertCallbackMemory callback, ILogLineMemoryColumnizer columnizer)
{
var openForms = Application.OpenForms;
foreach (Form form in openForms)
{
if (form.TopLevel && form.Name.Equals("LogTabWindow", StringComparison.OrdinalIgnoreCase) && form.Text.Contains(callback.GetFileName(), StringComparison.Ordinal))
{
form.BeginInvoke(FlashWindow, [form]);
_ = form.BeginInvoke(FlashWindow, [form]);
}
}
}

/// <summary>
/// Flash Window http://blogs.x2line.com/al/archive/2008/04/19/3392.aspx
/// </summary>
/// <param name="form"></param>
private void FlashWindow (Form form)
{
FLASHWINFO fw = new()
{
cbSize = Convert.ToUInt32(Marshal.SizeOf(typeof(FLASHWINFO))),
cbSize = Convert.ToUInt32(Marshal.SizeOf<FLASHWINFO>()),
hwnd = form.Handle,
dwFlags = 14,
dwFlags = FLASHW.FLASHW_TRAY | FLASHW.FLASHW_CAPTION | FLASHW.FLASHW_TIMER,
uCount = 0
};

Win32Stuff.FlashWindowEx(ref fw);
_ = FlashWindowEx(fw);
}

public string GetDescription ()
Expand Down
28 changes: 0 additions & 28 deletions src/FlashIconHighlighter/Win32Stuff.cs

This file was deleted.

14 changes: 6 additions & 8 deletions src/LogExpert.Core/Classes/Filter/FilterPipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using ColumnizerLib;

using LogExpert.Core.Interface;

using NLog;

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

#region cTor

public FilterPipe(FilterParams filterParams, ILogWindow logWindow)
public FilterPipe (FilterParams filterParams, ILogWindow logWindow)
{
FilterParams = filterParams;
LogWindow = logWindow;
Expand Down Expand Up @@ -68,15 +69,12 @@ public void OpenFile ()

public void CloseFile ()
{
if (_writer != null)
{
_writer.Close();
_writer = null;
}
_writer?.Close();
_writer = null;
}

//TOOD: check if the callers are checking for null before calling
public bool WriteToPipe (ILogLine textLine, int orgLineNum)
public bool WriteToPipe (ILogLineMemory textLine, int orgLineNum)
{
ArgumentNullException.ThrowIfNull(textLine, nameof(textLine));

Expand All @@ -88,7 +86,7 @@ public bool WriteToPipe (ILogLine textLine, int orgLineNum)
{
try
{
_writer.WriteLine(textLine.FullLine);
_writer.WriteLine(textLine.FullLine.ToString());
_lineMappingList.Add(orgLineNum);
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/LogExpert.Core/Classes/Log/LogfileReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1277,15 +1277,15 @@ private void ReadToBufferList (ILogFileInfo logFileInfo, long filePos, int start
}
}

AcquireDisposeReaderLock();
AcquireDisposeLockUpgradableReadLock();
if (logBuffer.IsDisposed)
{
UpgradeDisposeLockToWriterLock();
ReReadBuffer(logBuffer);
DowngradeDisposeLockFromWriterLock();
}

ReleaseDisposeReaderLock();
ReleaseDisposeUpgradeableReadLock();
}
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace LogExpert.Core.EventArguments;

public class ContextMenuPluginEventArgs(IContextMenuEntry entry, IList<int> logLines, ILogLineMemoryColumnizer columnizer,
ILogExpertCallback callback) : System.EventArgs
public class ContextMenuPluginEventArgs (IContextMenuEntry entry, IList<int> logLines, ILogLineMemoryColumnizer columnizer,
ILogExpertCallbackMemory callback) : EventArgs
{

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

public ILogLineMemoryColumnizer Columnizer { get; } = columnizer;

public ILogExpertCallback Callback { get; } = callback;
public ILogExpertCallbackMemory Callback { get; } = callback;

#endregion
}
15 changes: 15 additions & 0 deletions src/LogExpert.Core/Interface/ILogWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,21 @@ public interface ILogWindow
/// </remarks>
void WritePipeTab (IList<LineEntry> lineEntryList, string title);

/// <summary>
/// Creates a new tab containing the specified list of log line entries.
/// </summary>
/// <param name="lineEntryList">
/// A list of <see cref="LineEntryMemory"/> objects containing the lines and their
/// original line numbers to display in the new tab.
/// </param>
/// <param name="title">The title to display on the tab.</param>
/// <remarks>
/// This method is used to pipe filtered or selected content into a new tab
/// without creating a physical file. The new tab maintains references to the
/// original line numbers for context.
/// </remarks>
void WritePipeTab (IList<LineEntryMemory> lineEntryList, string title);

/// <summary>
/// Activates this log window and brings it to the foreground.
/// </summary>
Expand Down
27 changes: 27 additions & 0 deletions src/LogExpert.Resources/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/LogExpert.Resources/Resources.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2115,4 +2115,10 @@ Fortfahren?</value>

LogExpert neu starten, um die Änderungen zu übernehmen?</value>
</data>
<data name="LogExpert_Common_Error_Message_ServiceNotInitialized" xml:space="preserve">
<value>{0} nicht initialisiert</value>
</data>
<data name="LogExpert_Common_Error_Message_ServiceIsAlreadyInitialized" xml:space="preserve">
<value>{0} ist bereits initialisiert</value>
</data>
</root>
9 changes: 9 additions & 0 deletions src/LogExpert.Resources/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2124,4 +2124,13 @@ Restart LogExpert to apply changes?</value>
<data name="MissingFilesDialog_UI_Filter_Title" xml:space="preserve">
<value>Locate: {0}</value>
</data>
<data name="LogExpert_Common_Error_Message_ServiceNotInitialized" xml:space="preserve">
<value>{0} not initialized</value>
</data>
<data name="LogExpert_Common_Error_Message_ServiceIsAlreadyInitialized" xml:space="preserve">
<value>{0} is already initialized</value>
</data>
<data name="LogExpert_Common_Error_Message_ServiceMustBeCreatedOnUIThread" xml:space="preserve">
<value>{0} must be created on UI thread</value>
</data>
</root>
Loading