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
4 changes: 2 additions & 2 deletions src/ColumnizerLib/IAutoLogLineColumnizerCallback.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace LogExpert
namespace LogExpert
{
public interface IAutoLogLineColumnizerCallback
{
Expand All @@ -7,6 +7,6 @@ public interface IAutoLogLineColumnizerCallback
/// </summary>
/// <param name="lineNum">Number of the line to be retrieved</param>
/// <returns>A string with line content or null if line number is out of range</returns>
ILogLine GetLogLine(int lineNum);
ILogLine GetLogLine (int lineNum);
}
}
85 changes: 45 additions & 40 deletions src/ColumnizerLib/ILogLineColumnizerCallback.cs
Original file line number Diff line number Diff line change
@@ -1,47 +1,52 @@
namespace LogExpert
namespace LogExpert;

///<summary>
///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.
///</summary>
///<remarks>
///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.<br></br>
///<br></br>
///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.
///</remarks>
public interface ILogLineColumnizerCallback
{
///<summary>
///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.
///</summary>
///<remarks>
///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.<br></br>
///<br></br>
///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.
///</remarks>
public interface ILogLineColumnizerCallback
{
#region Public methods
#region Public methods

/// <summary>
/// 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).
/// </summary>
/// <returns>The current line number starting at 0</returns>
int GetLineNum();
/// <summary>
/// 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).
/// </summary>
/// <returns>The current line number starting at 0</returns>
int GetLineNum ();

/// <summary>
/// Returns the full file name (path + name) of the current log file.
/// </summary>
/// <returns>File name of current log file</returns>
string GetFileName();
/// <summary>
/// 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).
/// </summary>
/// <param name="lineNum">line number to be set</param>
void SetLineNum (int lineNum);
/// <summary>
/// Returns the full file name (path + name) of the current log file.
/// </summary>
/// <returns>File name of current log file</returns>
string GetFileName ();

/// <summary>
/// Returns the log line with the given index (zero-based).
/// </summary>
/// <param name="lineNum">Number of the line to be retrieved</param>
/// <returns>A string with line content or null if line number is out of range</returns>
ILogLine GetLogLine(int lineNum);
/// <summary>
/// Returns the log line with the given index (zero-based).
/// </summary>
/// <param name="lineNum">Number of the line to be retrieved</param>
/// <returns>A string with line content or null if line number is out of range</returns>
ILogLine GetLogLine (int lineNum);

/// <summary>
/// Returns the number of lines of the logfile.
/// </summary>
/// <returns>Number of lines.</returns>
int GetLineCount();
/// <summary>
/// Returns the number of lines of the logfile.
/// </summary>
/// <returns>Number of lines.</returns>
int GetLineCount ();

#endregion
}
#endregion
}
2 changes: 1 addition & 1 deletion src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PackageVersion Include="NUnit3TestAdapter" Version="5.0.0" />
<PackageVersion Include="SSH.NET" Version="2024.2.0" />
<PackageVersion Include="System.Data.DataSetExtensions" Version="4.5.0" />
<PackageVersion Include="System.Drawing.Common" Version="9.0.3" />
<PackageVersion Include="System.Drawing.Common" Version="9.0.5" />
<PackageVersion Include="System.Resources.Extensions" Version="9.0.3" />
<PackageVersion Include="System.Text.Encoding" Version="4.3.0" />
</ItemGroup>
Expand Down
99 changes: 50 additions & 49 deletions src/LogExpert.Core/Callback/ColumnizerCallback.cs
Original file line number Diff line number Diff line change
@@ -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<ILogLineColumnizer> GetRegisteredColumnizers()
{
return _pluginRegistry.RegisteredColumnizers;
}
public IList<ILogLineColumnizer> 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
}
31 changes: 14 additions & 17 deletions src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

using static LogExpert.Core.Classes.Columnizer.TimeFormatDeterminer;
Expand All @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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)
{
Expand All @@ -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<string>(GetColumnCount());
if (_isTimeExists)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<Column> columnList = [];
int restColumn = _columnCount;
Expand Down Expand Up @@ -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<ILogLine> samples)
public Priority GetPriority (string fileName, IEnumerable<ILogLine> samples)
{
Priority result = Priority.NotSupport;
TimeFormatDeterminer timeDeterminer = new();
Expand Down
Loading
Loading