diff --git a/.vs/LogWriter.git/v16/.suo b/.vs/LogWriter.git/v16/.suo index aab4a93..c445ed3 100644 Binary files a/.vs/LogWriter.git/v16/.suo and b/.vs/LogWriter.git/v16/.suo differ diff --git a/LogWriter/AppResources.Designer.cs b/LogWriter/AppResources.Designer.cs index 0c426eb..a118a77 100644 --- a/LogWriter/AppResources.Designer.cs +++ b/LogWriter/AppResources.Designer.cs @@ -61,7 +61,7 @@ namespace Eugen.ESystem.IO { } /// - /// Sucht eine lokalisierte Zeichenfolge, die The directory specifyed in Path was not found ähnelt. + /// Sucht eine lokalisierte Zeichenfolge, die The directory specifyed in Path was not found. ähnelt. /// internal static string msg001 { get { diff --git a/LogWriter/AppResources.de.resx b/LogWriter/AppResources.de.resx index ce88b00..e358631 100644 --- a/LogWriter/AppResources.de.resx +++ b/LogWriter/AppResources.de.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Das in Pfad angegebene Verzeichnis wurde nicht gefunden + Das in Pfad angegebene Verzeichnis wurde nicht gefunden. FileFormat hat das falsche Format. diff --git a/LogWriter/AppResources.resx b/LogWriter/AppResources.resx index 6a80247..59c633f 100644 --- a/LogWriter/AppResources.resx +++ b/LogWriter/AppResources.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - The directory specifyed in Path was not found + The directory specifyed in Path was not found. FileFormat has the wrong format. diff --git a/LogWriter/LogWriter.cs b/LogWriter/LogWriter.cs index 7a79df9..b80faac 100644 --- a/LogWriter/LogWriter.cs +++ b/LogWriter/LogWriter.cs @@ -129,6 +129,14 @@ namespace Eugen.ESystem.IO protected string ProgramCopyright { private set; get; } #endregion + #region enum + public enum Time + { + Write, + NoWrite + } + #endregion + #region delegates /// /// Provides a method, wich handles events from written messages @@ -271,23 +279,6 @@ namespace Eugen.ESystem.IO this.filename.Replace(".log", ""); } } - - /// - /// Constructor (Filename = self defined, with fileheader) - /// - /// - /// - /// - public LogWriter(string path, string filename, string logheader) - { - this.path = path; - this.filename = filename; - if (this.filename.EndsWith(".log")) - { - this.filename.Replace(".log", ""); - } - this.logheader = logheader; - } #endregion #region public members @@ -297,6 +288,17 @@ namespace Eugen.ESystem.IO /// Specifyes the message to be written /// Wheather the writing progress was successful public bool WriteMessage(string message) + { + return WriteMessage(message, Time.Write); + } + + /// + /// Writes a message + /// + /// Specifyes the message to be written + /// Indicates whether the time is written or not + /// Wheather the writing progress was successful + public bool WriteMessage(string message, Time writeTime) { // if directory not exists, cancel if (!Directory.Exists(this.path)) @@ -305,6 +307,8 @@ namespace Eugen.ESystem.IO // holds the actual date and time DateTime time = DateTime.Now; int ms = time.Millisecond; + string fmt = "000"; + string ms3 = ms.ToString(fmt); // creates the file name string fileName; @@ -369,7 +373,15 @@ namespace Eugen.ESystem.IO try { // creates the line - line = String.Format(this.messageFormat, new object[] { time, ms, message }); + if (writeTime == Time.Write) + { + line = String.Format(this.messageFormat, new object[] { time, ms3, message }); + } + else + { + line = String.Empty; + line = message; + } } catch (FormatException) { @@ -384,26 +396,6 @@ namespace Eugen.ESystem.IO { StreamWriter writer; - // if a log header is to be written - if (!String.IsNullOrEmpty(logheader) && IsFileEmpty(fileName)) - { - // write log header - // open file - if (!File.Exists(fileName)) - { - writer = new StreamWriter(fileName); - OnFileCreated(EventArgs.Empty); - } - else - writer = new StreamWriter(fileName); - - // write message line - writer.WriteLine(this.logheader); - - // close file - writer.Close(); - } - // open file if (!File.Exists(fileName)) { @@ -411,7 +403,9 @@ namespace Eugen.ESystem.IO OnFileCreated(EventArgs.Empty); } else + { writer = new StreamWriter(fileName, true); + } // write message line writer.WriteLine(line); @@ -530,6 +524,7 @@ namespace Eugen.ESystem.IO /// Constructor /// /// Specifyes the message post time + /// Specifyes the message post milliseconds /// Specifyes the message public LogWriterEventArgs(DateTime time, int millisecond, string message) : base() diff --git a/LogWriter/bin/Debug/de/helogwri.resources.dll b/LogWriter/bin/Debug/de/helogwri.resources.dll index 501e153..e11c3bc 100644 Binary files a/LogWriter/bin/Debug/de/helogwri.resources.dll and b/LogWriter/bin/Debug/de/helogwri.resources.dll differ diff --git a/LogWriter/bin/Debug/en/helogwri.resources.dll b/LogWriter/bin/Debug/en/helogwri.resources.dll index 357408a..b280c61 100644 Binary files a/LogWriter/bin/Debug/en/helogwri.resources.dll and b/LogWriter/bin/Debug/en/helogwri.resources.dll differ diff --git a/LogWriter/bin/Debug/helogwri.dll b/LogWriter/bin/Debug/helogwri.dll index 0da0a85..3fc13a0 100644 Binary files a/LogWriter/bin/Debug/helogwri.dll and b/LogWriter/bin/Debug/helogwri.dll differ diff --git a/LogWriter/bin/Debug/helogwri.pdb b/LogWriter/bin/Debug/helogwri.pdb index 1e53ce6..7a0b880 100644 Binary files a/LogWriter/bin/Debug/helogwri.pdb and b/LogWriter/bin/Debug/helogwri.pdb differ diff --git a/LogWriter/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/LogWriter/obj/Debug/DesignTimeResolveAssemblyReferences.cache index 7e61149..e7183b8 100644 Binary files a/LogWriter/obj/Debug/DesignTimeResolveAssemblyReferences.cache and b/LogWriter/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/LogWriter/obj/Debug/LogWriter.AppResources.de.resources b/LogWriter/obj/Debug/LogWriter.AppResources.de.resources index fd5d9c1..f35a8ce 100644 Binary files a/LogWriter/obj/Debug/LogWriter.AppResources.de.resources and b/LogWriter/obj/Debug/LogWriter.AppResources.de.resources differ diff --git a/LogWriter/obj/Debug/LogWriter.AppResources.resources b/LogWriter/obj/Debug/LogWriter.AppResources.resources index b529c89..4d90900 100644 Binary files a/LogWriter/obj/Debug/LogWriter.AppResources.resources and b/LogWriter/obj/Debug/LogWriter.AppResources.resources differ diff --git a/LogWriter/obj/Debug/LogWriter.csproj.AssemblyReference.cache b/LogWriter/obj/Debug/LogWriter.csproj.AssemblyReference.cache index 3e62bac..3a8bb1e 100644 Binary files a/LogWriter/obj/Debug/LogWriter.csproj.AssemblyReference.cache and b/LogWriter/obj/Debug/LogWriter.csproj.AssemblyReference.cache differ diff --git a/LogWriter/obj/Debug/LogWriter.csproj.FileListAbsolute.txt b/LogWriter/obj/Debug/LogWriter.csproj.FileListAbsolute.txt index 0847dbc..a652a10 100644 --- a/LogWriter/obj/Debug/LogWriter.csproj.FileListAbsolute.txt +++ b/LogWriter/obj/Debug/LogWriter.csproj.FileListAbsolute.txt @@ -1,13 +1,14 @@ -H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\LogWriter\obj\Debug\LogWriter.csproj.CoreCompileInputs.cache H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\LogWriter\bin\Debug\helogwri.dll H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\LogWriter\bin\Debug\helogwri.pdb -H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\LogWriter\obj\Debug\helogwri.dll -H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\LogWriter\obj\Debug\helogwri.pdb +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\LogWriter\bin\Debug\de\helogwri.resources.dll +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\LogWriter\bin\Debug\en\helogwri.resources.dll +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\LogWriter\obj\Debug\LogWriter.csproj.AssemblyReference.cache H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\LogWriter\obj\Debug\LogWriter.AppResources.resources H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\LogWriter\obj\Debug\LogWriter.AppResources.de.resources H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\LogWriter\obj\Debug\LogWriter.AppResources.en.resources H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\LogWriter\obj\Debug\LogWriter.csproj.GenerateResource.cache -H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\LogWriter\bin\Debug\de\helogwri.resources.dll -H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\LogWriter\bin\Debug\en\helogwri.resources.dll +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\LogWriter\obj\Debug\LogWriter.csproj.CoreCompileInputs.cache H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\LogWriter\obj\Debug\de\helogwri.resources.dll H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\LogWriter\obj\Debug\en\helogwri.resources.dll +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\LogWriter\obj\Debug\helogwri.dll +H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\LogWriter\obj\Debug\helogwri.pdb diff --git a/LogWriter/obj/Debug/LogWriter.csproj.GenerateResource.cache b/LogWriter/obj/Debug/LogWriter.csproj.GenerateResource.cache index 6953e19..0fcc4c5 100644 Binary files a/LogWriter/obj/Debug/LogWriter.csproj.GenerateResource.cache and b/LogWriter/obj/Debug/LogWriter.csproj.GenerateResource.cache differ diff --git a/LogWriter/obj/Debug/TempPE/AppResources.Designer.cs.dll b/LogWriter/obj/Debug/TempPE/AppResources.Designer.cs.dll index 1c00df1..677248e 100644 Binary files a/LogWriter/obj/Debug/TempPE/AppResources.Designer.cs.dll and b/LogWriter/obj/Debug/TempPE/AppResources.Designer.cs.dll differ diff --git a/LogWriter/obj/Debug/de/helogwri.resources.dll b/LogWriter/obj/Debug/de/helogwri.resources.dll index 501e153..e11c3bc 100644 Binary files a/LogWriter/obj/Debug/de/helogwri.resources.dll and b/LogWriter/obj/Debug/de/helogwri.resources.dll differ diff --git a/LogWriter/obj/Debug/en/helogwri.resources.dll b/LogWriter/obj/Debug/en/helogwri.resources.dll index 357408a..b280c61 100644 Binary files a/LogWriter/obj/Debug/en/helogwri.resources.dll and b/LogWriter/obj/Debug/en/helogwri.resources.dll differ diff --git a/LogWriter/obj/Debug/helogwri.dll b/LogWriter/obj/Debug/helogwri.dll index 0da0a85..3fc13a0 100644 Binary files a/LogWriter/obj/Debug/helogwri.dll and b/LogWriter/obj/Debug/helogwri.dll differ diff --git a/LogWriter/obj/Debug/helogwri.pdb b/LogWriter/obj/Debug/helogwri.pdb index 1e53ce6..7a0b880 100644 Binary files a/LogWriter/obj/Debug/helogwri.pdb and b/LogWriter/obj/Debug/helogwri.pdb differ diff --git a/Test_LogWriter/Form1.cs b/Test_LogWriter/Form1.cs index 49ebbc3..190aa4a 100644 --- a/Test_LogWriter/Form1.cs +++ b/Test_LogWriter/Form1.cs @@ -141,8 +141,9 @@ namespace Test_LogWriter 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); + string header = "--------------------\n Das ist der Header\n--------------------"; + var logWriter3 = new LogWriter(@"C:\TMP\", "my_logfile3"); + logWriter3.WriteMessage(header, LogWriter.Time.NoWrite); logWriter3.WriteMessage("Das ist Test 3"); labelResult.Text = String.Concat(labelResult.Text, "\nDie Log-Datei C:\\TMP\\my_logfile3.log wurde geschrieben"); } diff --git a/Test_LogWriter/bin/Debug/Test_LogWriter.exe b/Test_LogWriter/bin/Debug/Test_LogWriter.exe index e4b4369..7a3bfec 100644 Binary files a/Test_LogWriter/bin/Debug/Test_LogWriter.exe and b/Test_LogWriter/bin/Debug/Test_LogWriter.exe differ diff --git a/Test_LogWriter/bin/Debug/Test_LogWriter.pdb b/Test_LogWriter/bin/Debug/Test_LogWriter.pdb index f08617d..51285f9 100644 Binary files a/Test_LogWriter/bin/Debug/Test_LogWriter.pdb and b/Test_LogWriter/bin/Debug/Test_LogWriter.pdb differ diff --git a/Test_LogWriter/bin/Debug/de/helogwri.resources.dll b/Test_LogWriter/bin/Debug/de/helogwri.resources.dll index 501e153..e11c3bc 100644 Binary files a/Test_LogWriter/bin/Debug/de/helogwri.resources.dll and b/Test_LogWriter/bin/Debug/de/helogwri.resources.dll differ diff --git a/Test_LogWriter/bin/Debug/en/helogwri.resources.dll b/Test_LogWriter/bin/Debug/en/helogwri.resources.dll index 357408a..b280c61 100644 Binary files a/Test_LogWriter/bin/Debug/en/helogwri.resources.dll and b/Test_LogWriter/bin/Debug/en/helogwri.resources.dll differ diff --git a/Test_LogWriter/bin/Debug/helogwri.dll b/Test_LogWriter/bin/Debug/helogwri.dll index 0da0a85..3fc13a0 100644 Binary files a/Test_LogWriter/bin/Debug/helogwri.dll and b/Test_LogWriter/bin/Debug/helogwri.dll differ diff --git a/Test_LogWriter/bin/Debug/helogwri.pdb b/Test_LogWriter/bin/Debug/helogwri.pdb index 1e53ce6..7a0b880 100644 Binary files a/Test_LogWriter/bin/Debug/helogwri.pdb and b/Test_LogWriter/bin/Debug/helogwri.pdb differ diff --git a/Test_LogWriter/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/Test_LogWriter/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index f94c865..980e48a 100644 Binary files a/Test_LogWriter/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/Test_LogWriter/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/Test_LogWriter/obj/Debug/Test_LogWriter.csproj.AssemblyReference.cache b/Test_LogWriter/obj/Debug/Test_LogWriter.csproj.AssemblyReference.cache index 3393a62..1f4cde4 100644 Binary files a/Test_LogWriter/obj/Debug/Test_LogWriter.csproj.AssemblyReference.cache and b/Test_LogWriter/obj/Debug/Test_LogWriter.csproj.AssemblyReference.cache differ diff --git a/Test_LogWriter/obj/Debug/Test_LogWriter.csproj.FileListAbsolute.txt b/Test_LogWriter/obj/Debug/Test_LogWriter.csproj.FileListAbsolute.txt index 551097c..13f7524 100644 --- a/Test_LogWriter/obj/Debug/Test_LogWriter.csproj.FileListAbsolute.txt +++ b/Test_LogWriter/obj/Debug/Test_LogWriter.csproj.FileListAbsolute.txt @@ -1,17 +1,17 @@ +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\heshowtf.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\bin\Debug\heshowtf.pdb +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\obj\Debug\Test_LogWriter.csproj.AssemblyReference.cache H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\obj\Debug\Test_LogWriter.Form1.resources H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\obj\Debug\Test_LogWriter.Properties.Resources.resources H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\obj\Debug\Test_LogWriter.csproj.GenerateResource.cache H:\Programmieren\Git-WorkRepository\VisualStudio\_DLL\LogWriter.git\Test_LogWriter\obj\Debug\Test_LogWriter.csproj.CoreCompileInputs.cache -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.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 -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 diff --git a/Test_LogWriter/obj/Debug/Test_LogWriter.csproj.GenerateResource.cache b/Test_LogWriter/obj/Debug/Test_LogWriter.csproj.GenerateResource.cache index 2946fe2..fee9892 100644 Binary files a/Test_LogWriter/obj/Debug/Test_LogWriter.csproj.GenerateResource.cache and b/Test_LogWriter/obj/Debug/Test_LogWriter.csproj.GenerateResource.cache differ diff --git a/Test_LogWriter/obj/Debug/Test_LogWriter.exe b/Test_LogWriter/obj/Debug/Test_LogWriter.exe index e4b4369..7a3bfec 100644 Binary files a/Test_LogWriter/obj/Debug/Test_LogWriter.exe and b/Test_LogWriter/obj/Debug/Test_LogWriter.exe differ diff --git a/Test_LogWriter/obj/Debug/Test_LogWriter.pdb b/Test_LogWriter/obj/Debug/Test_LogWriter.pdb index f08617d..51285f9 100644 Binary files a/Test_LogWriter/obj/Debug/Test_LogWriter.pdb and b/Test_LogWriter/obj/Debug/Test_LogWriter.pdb differ