Änderung
- Anzeige von Millisekunden bei der Zeitangabe in der Logzeile dazu
This commit is contained in:
parent
07a3c208d5
commit
992880be1e
Binary file not shown.
@ -163,7 +163,7 @@ namespace Eugen.ESystem.IO
|
||||
/// <summary>
|
||||
/// Stores the message format
|
||||
/// </summary>
|
||||
private string messageFormat = "{0:T}: {1}";
|
||||
private string messageFormat = "{0:T}.{1}: {2}";
|
||||
#endregion
|
||||
|
||||
#region events
|
||||
@ -304,6 +304,7 @@ namespace Eugen.ESystem.IO
|
||||
|
||||
// holds the actual date and time
|
||||
DateTime time = DateTime.Now;
|
||||
int ms = time.Millisecond;
|
||||
|
||||
// creates the file name
|
||||
string fileName;
|
||||
@ -362,14 +363,13 @@ namespace Eugen.ESystem.IO
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// build message line
|
||||
string line;
|
||||
try
|
||||
{
|
||||
// creates the line
|
||||
line = String.Format(this.messageFormat, new object[] { time, message });
|
||||
line = String.Format(this.messageFormat, new object[] { time, ms, message });
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
@ -419,7 +419,7 @@ namespace Eugen.ESystem.IO
|
||||
// close file
|
||||
writer.Close();
|
||||
|
||||
OnMessageWritten(new LogWriterEventArgs(time, message));
|
||||
OnMessageWritten(new LogWriterEventArgs(time, ms, message));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -488,6 +488,8 @@ namespace Eugen.ESystem.IO
|
||||
/// </summary>
|
||||
private DateTime time;
|
||||
|
||||
private int millisecond;
|
||||
|
||||
/// <summary>
|
||||
/// Stores the message
|
||||
/// </summary>
|
||||
@ -526,10 +528,11 @@ namespace Eugen.ESystem.IO
|
||||
/// </summary>
|
||||
/// <param name="time">Specifyes the message post time</param>
|
||||
/// <param name="message">Specifyes the message</param>
|
||||
public LogWriterEventArgs(DateTime time, string message)
|
||||
public LogWriterEventArgs(DateTime time, int millisecond, string message)
|
||||
: base()
|
||||
{
|
||||
this.time = time;
|
||||
this.millisecond = millisecond;
|
||||
this.message = message;
|
||||
}
|
||||
#endregion
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -134,7 +134,7 @@ namespace Test_LogWriter
|
||||
var logWriter1 = new LogWriter(@"C:\TMP\");
|
||||
logWriter1.WriteMessage("Das ist ein Test");
|
||||
|
||||
//Variante 2 - Logdateiname wird angegeben, z.B. 'my_logfile.log'
|
||||
//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");
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -6,8 +6,8 @@ H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWrit
|
||||
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\bin\Debug\Test_LogWriter.exe.config
|
||||
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\bin\Debug\Test_LogWriter.exe
|
||||
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\bin\Debug\Test_LogWriter.pdb
|
||||
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\helogwri.pdb
|
||||
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\obj\Debug\Test_LogWriter.csproj.CopyComplete
|
||||
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\obj\Debug\Test_LogWriter.exe
|
||||
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\obj\Debug\Test_LogWriter.pdb
|
||||
H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\bin\Debug\helogwri.dll
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user