Änderung

- Testroutine überarbeitet
   - Es werden drei unterschiedliche Log-File-Typen erzeugt
      - Normale Logdatei mit automatisch generiertem Dateinamen
      - Normale Logdate mit benutzerdefiniertem Dateinamen
      - Logdatei mit benutzerdefiniertem Dateinamen und Dateikopf
   - Anzeigemöglichkeit der drei Dateien über Schaltfläche
This commit is contained in:
Eugen Höglinger 2021-09-07 12:09:14 +02:00
parent 95cd3a8013
commit adbb61a3fd
16 changed files with 83 additions and 3 deletions

Binary file not shown.

View File

@ -35,6 +35,9 @@ namespace Test_LogWriter
this.groupBoxDLLInfo = new System.Windows.Forms.GroupBox();
this.labelDLLInfo = new System.Windows.Forms.Label();
this.labelResult = new System.Windows.Forms.Label();
this.buttonShowLog1 = new System.Windows.Forms.Button();
this.buttonShowLog2 = new System.Windows.Forms.Button();
this.buttonShowLog3 = new System.Windows.Forms.Button();
this.groupBoxProgramInfo.SuspendLayout();
this.groupBoxDLLInfo.SuspendLayout();
this.SuspendLayout();
@ -98,11 +101,44 @@ namespace Test_LogWriter
this.labelResult.TabIndex = 13;
this.labelResult.Text = "...";
//
// buttonShowLog1
//
this.buttonShowLog1.Location = new System.Drawing.Point(12, 258);
this.buttonShowLog1.Name = "buttonShowLog1";
this.buttonShowLog1.Size = new System.Drawing.Size(160, 23);
this.buttonShowLog1.TabIndex = 14;
this.buttonShowLog1.Text = "Log-Datei 1 anzeigen";
this.buttonShowLog1.UseVisualStyleBackColor = true;
this.buttonShowLog1.Click += new System.EventHandler(this.buttonShowLog1_Click);
//
// buttonShowLog2
//
this.buttonShowLog2.Location = new System.Drawing.Point(320, 258);
this.buttonShowLog2.Name = "buttonShowLog2";
this.buttonShowLog2.Size = new System.Drawing.Size(160, 23);
this.buttonShowLog2.TabIndex = 15;
this.buttonShowLog2.Text = "Log-Datei 2 anzeigen";
this.buttonShowLog2.UseVisualStyleBackColor = true;
this.buttonShowLog2.Click += new System.EventHandler(this.buttonShowLog2_Click);
//
// buttonShowLog3
//
this.buttonShowLog3.Location = new System.Drawing.Point(628, 258);
this.buttonShowLog3.Name = "buttonShowLog3";
this.buttonShowLog3.Size = new System.Drawing.Size(160, 23);
this.buttonShowLog3.TabIndex = 16;
this.buttonShowLog3.Text = "Log-Datei 3 anzeigen";
this.buttonShowLog3.UseVisualStyleBackColor = true;
this.buttonShowLog3.Click += new System.EventHandler(this.buttonShowLog3_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.buttonShowLog3);
this.Controls.Add(this.buttonShowLog2);
this.Controls.Add(this.buttonShowLog1);
this.Controls.Add(this.labelResult);
this.Controls.Add(this.groupBoxProgramInfo);
this.Controls.Add(this.groupBoxDLLInfo);
@ -127,6 +163,9 @@ namespace Test_LogWriter
private System.Windows.Forms.GroupBox groupBoxDLLInfo;
private System.Windows.Forms.Label labelDLLInfo;
private System.Windows.Forms.Label labelResult;
private System.Windows.Forms.Button buttonShowLog1;
private System.Windows.Forms.Button buttonShowLog2;
private System.Windows.Forms.Button buttonShowLog3;
}
}

View File

@ -132,16 +132,52 @@ namespace Test_LogWriter
{
//Variante 1 - Logdateiname ist automatisch 'log_dd-mm-yy.log'
var logWriter1 = new LogWriter(@"C:\TMP\");
logWriter1.WriteMessage("Das ist ein Test");
logWriter1.WriteMessage("Das ist Test 1");
labelResult.Text = String.Concat("Die Log-Datei C:\\TMP\\log_", DateTime.Now.Date.ToString().Remove(10), ".log wurde geschrieben.");
//Variante 2 - Logdateiname wird angegeben, z.B. 'my_logfile2.log'
var logWriter2 = new LogWriter(@"C:\TMP\", "my_logfile2.log");
logWriter2.WriteMessage("Das ist Test 2");
labelResult.Text = String.Concat(labelResult.Text, "\nDie Log-Datei C:\\TMP\\my_logfile2.log wurde geschrieben");
//Variante 3 - Logdateiname wird angegeben und Header wird geschrieben
string header = "--------------------\nDas ist der Header\n--------------------";
var logWriter3 = new LogWriter(@"C:\TMP\", "my_logfile3", header);
logWriter3.WriteMessage("Das ist Test 3");
labelResult.Text = String.Concat(labelResult.Text, "\nDie Log-Datei C:\\TMP\\my_logfile3.log wurde geschrieben");
}
private void buttonShowLog1_Click(object sender, EventArgs e)
{
string textFileName = String.Concat("C:\\TMP\\log_", DateTime.Now.Date.ToString().Remove(10), ".log");
//Wenn die Datei nicht angezeigt werden kann, dann eine Fehlermeldung ausgeben
if (!ShowTextFile.Show(textFileName))
{
MessageBox.Show("Entweder die Datei existiert nicht oder der Editor konnte nicht geöffnet werden!");
}
}
private void buttonShowLog2_Click(object sender, EventArgs e)
{
string textFileName = "C:\\TMP\\my_logfile2.log";
//Wenn die Datei nicht angezeigt werden kann, dann eine Fehlermeldung ausgeben
if (!ShowTextFile.Show(textFileName))
{
MessageBox.Show("Entweder die Datei existiert nicht oder der Editor konnte nicht geöffnet werden!");
}
}
private void buttonShowLog3_Click(object sender, EventArgs e)
{
string textFileName = "C:\\TMP\\my_logfile3.log";
//Wenn die Datei nicht angezeigt werden kann, dann eine Fehlermeldung ausgeben
if (!ShowTextFile.Show(textFileName))
{
MessageBox.Show("Entweder die Datei existiert nicht oder der Editor konnte nicht geöffnet werden!");
}
}
}
}

View File

@ -36,6 +36,9 @@
<Reference Include="helogwri">
<HintPath>..\LogWriter\bin\Debug\helogwri.dll</HintPath>
</Reference>
<Reference Include="heshowtf">
<HintPath>..\..\ShowTextFile.git\ShowTextFile\bin\Debug\heshowtf.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
c22a14cd5e15cda5a8e1291702aaf3f81bc0cc03
b69314ac7e0577ff976a8ba62b6b4dc25ca31ef0

View File

@ -13,3 +13,5 @@ H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWrit
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\bin\Debug\helogwri.dll
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\bin\Debug\de\helogwri.resources.dll
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\bin\Debug\en\helogwri.resources.dll
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\bin\Debug\heshowtf.dll
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\bin\Debug\heshowtf.pdb