Skip to content

Commit ff1b514

Browse files
committed
optimisations
1 parent db51888 commit ff1b514

24 files changed

Lines changed: 423 additions & 75 deletions

File tree

src/AutoColumnizer/AutoColumnizer.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System;
2-
31
using LogExpert;
42

53
namespace AutoColumnizer;
@@ -20,6 +18,11 @@ public string GetName ()
2018
return "Auto Columnizer";
2119
}
2220

21+
public string GetCustomName ()
22+
{
23+
return GetName();
24+
}
25+
2326
public string GetDescription ()
2427
{
2528
return "Automatically find the right columnizer for any file";

src/ColumnizerLib/ILogLineColumnizer.cs

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
using System;
2-
31
namespace LogExpert;
42

53
///<summary>
64
/// This interface defines a so-called 'Columnizer' for LogExpert.
75
/// A columnizer splits a single text line into well defined columns. These columns
86
/// are used in the data grid view of LogExpert.
9-
/// <br></br><br></br>
7+
/// <br></br><br></br>
108
/// Optionally a columnizer can parse the log line to determine the date/time of
119
/// the log line (assuming that all log lines have a timestamp). This is needed for
1210
/// some of the features of LogExpert (see user documentation for more information).
@@ -20,45 +18,50 @@ public interface ILogLineColumnizer
2018
/// <summary>
2119
/// Returns the name for the columnizer. This name is used for the columnizer selection dialog.
2220
/// </summary>
23-
string GetName();
21+
string GetName ();
22+
23+
/// <summary>
24+
/// Returns the name that is given by the user for this columnizer.
25+
/// </summary>
26+
string GetCustomName ();
2427

2528
/// <summary>
2629
/// Returns the description of the columnizer. This text is used in the columnizer selection dialog.
2730
/// </summary>
28-
string GetDescription();
31+
string GetDescription ();
2932

3033
/// <summary>
31-
/// Returns the number of columns the columnizer will split lines into.
34+
/// Returns the number of columns the columnizer will split lines into.
3235
/// </summary>
3336
/// <remarks>
34-
/// This value does not include the column for displaying the line number. The line number column
37+
/// This value does not include the column for displaying the line number. The line number column
3538
/// is added by LogExpert and is not handled by columnizers.
3639
/// </remarks>
37-
int GetColumnCount();
40+
int GetColumnCount ();
3841

3942
/// <summary>
4043
/// Returns the names of the columns. The returned names are used by LogExpert for the column headers in the data grid view.
41-
/// The names are expected in order from left to right.
44+
/// The names are expected in order from left to right.
4245
/// </summary>
43-
string[] GetColumnNames();
46+
string[] GetColumnNames ();
4447

4548
/// <summary>
46-
/// Given a single line of the logfile this function splits the line content into columns. The function returns
49+
/// Given a single line of the logfile this function splits the line content into columns. The function returns
4750
/// a string array containing the splitted content.
4851
/// </summary>
4952
/// <remarks>
5053
/// This function is called by LogExpert for every line that has to be drawn in the grid view. The faster your code
5154
/// handles the splitting, the faster LogExpert can draw the grid view content.<br></br>
5255
/// <br></br>
5356
/// Notes about timeshift handling:<br></br>
54-
/// If your columnizer implementation supports timeshift (see <see cref="IsTimeshiftImplemented">IsTimeshiftImplemented</see>)
57+
/// If your columnizer implementation supports timeshift (see <see cref="IsTimeshiftImplemented">IsTimeshiftImplemented</see>)
5558
/// you have to add the timestamp offset to the columns representing the timestamp (e.g. columns like 'date' and 'time').
56-
/// In practice this means you have to parse the date/time value of your log line (see <see cref="GetTimestamp">GetTimestamp</see>)
59+
/// In practice this means you have to parse the date/time value of your log line (see <see cref="GetTimestamp">GetTimestamp</see>)
5760
/// add the offset and convert the timestamp back to string value(s).
5861
/// </remarks>
5962
/// <param name="callback">Callback interface with functions which can be used by the columnizer</param>
6063
/// <param name="line">The line content to be splitted</param>
61-
IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line);
64+
IColumnizedLogLine SplitLine (ILogLineColumnizerCallback callback, ILogLine line);
6265

6366
/// <summary>
6467
/// Returns true, if the columnizer supports timeshift handling.
@@ -67,23 +70,23 @@ public interface ILogLineColumnizer
6770
/// If you return true, you also have to implement the function SetTimeOffset(), GetTimeOffset() and GetTimestamp().
6871
/// You also must handle PushValue() for the column(s) that displays the timestamp.
6972
/// </remarks>
70-
bool IsTimeshiftImplemented();
73+
bool IsTimeshiftImplemented ();
7174

7275
/// <summary>
73-
/// Sets an offset to be used for displaying timestamp values. You have to implement this function, if
76+
/// Sets an offset to be used for displaying timestamp values. You have to implement this function, if
7477
/// your IsTimeshiftImplemented() function return true.
7578
/// </summary>
7679
/// <remarks>
77-
/// You have to store the given value in the Columnizer instance and add this offset to the timestamp column(s) returned by SplitLine()
80+
/// You have to store the given value in the Columnizer instance and add this offset to the timestamp column(s) returned by SplitLine()
7881
/// (e.g. in the date and time columns).
7982
/// </remarks>
8083
/// <param name="msecOffset">The timestamp offset in milliseconds.</param>
81-
void SetTimeOffset(int msecOffset);
84+
void SetTimeOffset (int msecOffset);
8285

8386
/// <summary>
8487
/// Returns the current stored timestamp offset (set by SetTimeOffset()).
8588
/// </summary>
86-
int GetTimeOffset();
89+
int GetTimeOffset ();
8790

8891
/// <summary>
8992
/// Returns the timestamp value of the given line as a .NET DateTime object. If there's no valid timestamp in the
@@ -99,7 +102,7 @@ public interface ILogLineColumnizer
99102
/// </remarks>
100103
/// <param name="callback">Callback interface with functions which can be used by the columnizer</param>
101104
/// <param name="line">The line content which timestamp has to be returned.</param>
102-
DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line);
105+
DateTime GetTimestamp (ILogLineColumnizerCallback callback, ILogLine line);
103106

104107
/// <summary>
105108
/// This function is called if the user changes a value in a column (edit mode in the log view).
@@ -114,7 +117,7 @@ public interface ILogLineColumnizer
114117
/// <param name="column">The column number which value has changed.</param>
115118
/// <param name="value">The new value.</param>
116119
/// <param name="oldValue">The old value.</param>
117-
void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue);
120+
void PushValue (ILogLineColumnizerCallback callback, int column, string value, string oldValue);
118121

119122
#endregion
120123
}

src/CsvColumnizer/CsvColumnizer.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ public string GetName ()
7272
return "CSV Columnizer";
7373
}
7474

75+
public string GetCustomName ()
76+
{
77+
return GetName();
78+
}
79+
7580
public string GetDescription ()
7681
{
7782
return "Splits CSV files into columns.\r\n\r\nCredits:\r\nThis Columnizer uses the CsvHelper. https://github.com/JoshClose/CsvHelper. \r\n";

src/GlassfishColumnizer/GlassfishColumnizer.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal class GlassfishColumnizer : ILogLineXmlColumnizer
1313
public const int COLUMN_COUNT = 2;
1414
private const string DATETIME_FORMAT = "yyyy-MM-ddTHH:mm:ss.fffzzzz";
1515
private const string DATETIME_FORMAT_OUT = "yyyy-MM-dd HH:mm:ss.fff";
16-
private const char separatorChar = '|';
16+
private const char SEPARATOR_CHAR = '|';
1717

1818
private static readonly XmlConfig xmlConfig = new();
1919

@@ -42,7 +42,7 @@ public ILogLine GetLineTextForClipboard (ILogLine logLine, ILogLineColumnizerCal
4242
{
4343
GlassFishLogLine line = new()
4444
{
45-
FullLine = logLine.FullLine.Replace(separatorChar, '|'),
45+
FullLine = logLine.FullLine.Replace(SEPARATOR_CHAR, '|'),
4646
LineNumber = logLine.LineNumber
4747
};
4848

@@ -51,7 +51,12 @@ public ILogLine GetLineTextForClipboard (ILogLine logLine, ILogLineColumnizerCal
5151

5252
public string GetName ()
5353
{
54-
return "Classfish";
54+
return "Glassfish";
55+
}
56+
57+
public string GetCustomName ()
58+
{
59+
return GetName();
5560
}
5661

5762
public string GetDescription ()
@@ -171,7 +176,7 @@ public DateTime GetTimestamp (ILogLineColumnizerCallback callback, ILogLine logL
171176
return DateTime.MinValue;
172177
}
173178

174-
var endIndex = temp.IndexOf(separatorChar, 1);
179+
var endIndex = temp.IndexOf(SEPARATOR_CHAR, 1);
175180
if (endIndex is > 28 or < 0)
176181
{
177182
return DateTime.MinValue;

src/JsonColumnizer/JsonColumnizer.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,5 +216,10 @@ protected virtual IColumnizedLogLine SplitJsonLine (ILogLine line, JObject json)
216216
return cLogLine;
217217
}
218218

219+
public string GetCustomName ()
220+
{
221+
return GetName();
222+
}
223+
219224
#endregion
220225
}

src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public string GetName ()
5959
return "Log4j XML";
6060
}
6161

62+
public string GetCustomName () => GetName();
63+
6264
public string GetDescription ()
6365
{
6466
return "Reads and formats XML log files written with log4j.";

src/LogExpert.Core/Classes/Columnizer/ClfColumnizer.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,10 @@ public IColumnizedLogLine SplitLine (ILogLineColumnizerCallback callback, ILogLi
192192
return cLogLine;
193193
}
194194

195+
public string GetCustomName ()
196+
{
197+
return GetName();
198+
}
199+
195200
#endregion
196201
}

src/LogExpert.Core/Classes/Columnizer/SquareBracketColumnizer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ public string GetName ()
107107
return "Square Bracket Columnizer";
108108
}
109109

110+
public string GetCustomName () => GetName();
111+
110112
public string GetDescription ()
111113
{
112114
return "Splits every line into n fields: Date, Time and the rest of the log message";

src/LogExpert.Core/Classes/Columnizer/TimestampColumnizer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ public string GetName ()
8787
return "Timestamp Columnizer";
8888
}
8989

90+
public string GetCustomName () => GetName();
91+
9092
public string GetDescription ()
9193
{
9294
return "Splits every line into 3 fields: Date, Time and the rest of the log message";

0 commit comments

Comments
 (0)