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
407 changes: 202 additions & 205 deletions src/CsvColumnizer/CsvColumnizerConfigDlg.Designer.cs

Large diffs are not rendered by default.

33 changes: 20 additions & 13 deletions src/CsvColumnizer/CsvColumnizerConfigDlg.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Drawing;
using System.Windows.Forms;

namespace CsvColumnizer
Expand All @@ -15,9 +16,14 @@ public partial class CsvColumnizerConfigDlg : Form

public CsvColumnizerConfigDlg(CsvColumnizerConfig config)
{
SuspendLayout();
AutoScaleDimensions = new SizeF(96F, 96F);
AutoScaleMode = AutoScaleMode.Dpi;

_config = config;
InitializeComponent();
FillValues();
ResumeLayout();
}

#endregion
Expand All @@ -27,23 +33,23 @@ public CsvColumnizerConfigDlg(CsvColumnizerConfig config)
private void FillValues()
{
delimiterTextBox.Text = _config.DelimiterChar;
quoteCharTextBox.Text = _config.QuoteChar.ToString();
escapeCharTextBox.Text = _config.EscapeChar.ToString();
escapeCheckBox.Checked = _config.EscapeChar != '\0';
commentCharTextBox.Text = _config.CommentChar.ToString();
fieldNamesCheckBox.Checked = _config.HasFieldNames;
escapeCharTextBox.Enabled = escapeCheckBox.Checked;
minColumnsNumericUpDown.Value = _config.MinColumns;
textBoxQuoteChar.Text = _config.QuoteChar.ToString();
textboxEscapeChar.Text = _config.EscapeChar.ToString();
checkBoxEscape.Checked = _config.EscapeChar != '\0';
textBoxCommentChar.Text = _config.CommentChar.ToString();
checkBoxFieldNames.Checked = _config.HasFieldNames;
textboxEscapeChar.Enabled = checkBoxEscape.Checked;
numericUpDownMinColumns.Value = _config.MinColumns;
}

private void RetrieveValues()
{
_config.DelimiterChar = delimiterTextBox.Text;
_config.QuoteChar = quoteCharTextBox.Text[0];
_config.EscapeChar = escapeCheckBox.Checked ? escapeCharTextBox.Text[0] : '\0';
_config.CommentChar = commentCharTextBox.Text[0];
_config.HasFieldNames = fieldNamesCheckBox.Checked;
_config.MinColumns = (int) minColumnsNumericUpDown.Value;
_config.QuoteChar = textBoxQuoteChar.Text[0];
_config.EscapeChar = checkBoxEscape.Checked ? textboxEscapeChar.Text[0] : '\0';
_config.CommentChar = textBoxCommentChar.Text[0];
_config.HasFieldNames = checkBoxFieldNames.Checked;
_config.MinColumns = (int)numericUpDownMinColumns.Value;
}

#endregion
Expand All @@ -57,9 +63,10 @@ private void OnOkButtonClick(object sender, EventArgs e)

private void OnEscapeCheckBoxCheckedChanged(object sender, EventArgs e)
{
escapeCharTextBox.Enabled = escapeCheckBox.Checked;
textboxEscapeChar.Enabled = checkBoxEscape.Checked;
}

#endregion

}
}
54 changes: 27 additions & 27 deletions src/CsvColumnizer/CsvColumnizerConfigDlg.resx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema

Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes

The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.

Example:

... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
Expand All @@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple

There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the

Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not

The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can

Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.

mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
Expand Down
18 changes: 9 additions & 9 deletions src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;

using System;
using System.Collections.Generic;
using System.Globalization;
Expand Down Expand Up @@ -221,7 +222,6 @@ public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLin

Column[] columns = Column.CreateColumns(COLUMN_COUNT, clogLine);


// If the line is too short (i.e. does not follow the format for this columnizer) return the whole line content
// in colum 8 (the log message column). Date and time column will be left blank.
if (line.FullLine.Length < 15)
Expand All @@ -233,10 +233,12 @@ public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLin
try
{
DateTime dateTime = GetTimestamp(callback, line);

if (dateTime == DateTime.MinValue)
{
columns[8].FullValue = line.FullLine;
}

string newDate = dateTime.ToString(DATETIME_FORMAT);
columns[0].FullValue = newDate;
}
Expand Down Expand Up @@ -305,6 +307,7 @@ public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line)
}

int endIndex = line.FullLine.IndexOf(separatorChar, 1);

if (endIndex > 20 || endIndex < 0)
{
return DateTime.MinValue;
Expand All @@ -314,12 +317,12 @@ public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line)
try
{
// convert log4j timestamp into a readable format:
long timestamp;
if (long.TryParse(value, out timestamp))
if (long.TryParse(value, out long timestamp))
{
// Add the time offset before returning
DateTime dateTime = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
dateTime = dateTime.AddMilliseconds(timestamp);

if (_config.localTimestamps)
{
dateTime = dateTime.ToLocalTime();
Expand Down Expand Up @@ -347,7 +350,7 @@ public void PushValue(ILogLineColumnizerCallback callback, int column, string va
DateTime oldDateTime = DateTime.ParseExact(oldValue, DATETIME_FORMAT, cultureInfo);
long mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond;
long mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond;
timeOffset = (int) (mSecsNew - mSecsOld);
timeOffset = (int)(mSecsNew - mSecsOld);
}
catch (FormatException)
{
Expand Down Expand Up @@ -411,10 +414,7 @@ public Priority GetPriority(string fileName, IEnumerable<ILogLine> samples)

#region Private Methods

private string[] GetAllColumnNames()
{
return ["Timestamp", "Level", "Logger", "Thread", "Class", "Method", "File", "Line", "Message"];
}
private string[] GetAllColumnNames() => ["Timestamp", "Level", "Logger", "Thread", "Class", "Method", "File", "Line", "Message"];


/// <summary>
Expand Down Expand Up @@ -442,7 +442,7 @@ private Column[] MapColumns(Column[] cols)
}


return output.ToArray();
return [.. output];
}

#endregion
Expand Down
12 changes: 9 additions & 3 deletions src/Log4jXmlColumnizer/Log4jXmlColumnizerConfigDlg.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Drawing;
using System.Windows.Forms;

namespace LogExpert
Expand All @@ -15,10 +16,15 @@ public partial class Log4jXmlColumnizerConfigDlg : Form

public Log4jXmlColumnizerConfigDlg(Log4jXmlColumnizerConfig config)
{
SuspendLayout();
AutoScaleDimensions = new SizeF(96F, 96F);
AutoScaleMode = AutoScaleMode.Dpi;

_config = config;
InitializeComponent();
FillListBox();
localTimeCheckBox.Checked = _config.localTimestamps;
ResumeLayout();
}

#endregion
Expand All @@ -33,7 +39,7 @@ private void FillListBox()

foreach (Log4jColumnEntry entry in _config.columnList)
{
DataGridViewRow row = new DataGridViewRow();
DataGridViewRow row = new();
row.Cells.Add(new DataGridViewCheckBoxCell());
row.Cells.Add(new DataGridViewTextBoxCell());
row.Cells.Add(new DataGridViewTextBoxCell());
Expand All @@ -58,8 +64,8 @@ private void OkButton_Click(object sender, EventArgs e)
{
_config.columnList[i].visible = (bool)columnGridView.Rows[i].Cells[0].Value;
string sLen = (string)columnGridView.Rows[i].Cells[2].Value;
int len;
if (int.TryParse(sLen, out len))

if (int.TryParse(sLen, out int len))
{
_config.columnList[i].maxLen = len;
}
Expand Down
4 changes: 2 additions & 2 deletions src/RegexColumnizer/RegexColumnizerConfigDialog.Designer.cs

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

Loading