/[RomCheater]/trunk/RomCheater.Logging/LogWriter.cs
ViewVC logotype

Diff of /trunk/RomCheater.Logging/LogWriter.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater.Logging/LogWriter.cs	2012/05/09 08:16:18	18
+++ trunk/RomCheater.Logging/LogWriter.cs	2012/05/09 08:51:38	23
@@ -8,13 +8,13 @@
 using System.Text;
 using System.Windows.Forms;
 using System.IO;
+using System.Reflection;
 
 namespace RomCheater.Logging
 {
     public partial class LogWriter : UserControl
     {
-        private const string LOG_FILE = "RomCheater.log";
-        private static string LOG_PATH = string.Format(@"{0}\{1}", Application.StartupPath, LOG_FILE);
+        private static string LOG_PATH = string.Format(@"{0}\{1}", Application.StartupPath, LoggingConstants.AppLogFile);
 
         private delegate string OnGetLogText();
         private delegate void OnSetLogText(string value);
@@ -42,11 +42,6 @@
             sw = new StreamWriter(ms);
             sw.AutoFlush = true;
             sr = new StreamReader(ms);
-
-            FileInfo fi = new FileInfo(LOG_PATH);
-            if (fi.Exists)
-                fi.Delete();
-
         }
         private LogStream _Log;
         public LogStream Log { get { return _Log; } private set { _Log = value; } }
@@ -144,7 +139,8 @@
             FileStream fs = new FileStream(LOG_PATH, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
             StreamWriter writer = new StreamWriter(fs);
             writer.AutoFlush = true;
-            writer.Write(value);
+            if (value == Log.NewLine) { writer.Write(System.Environment.NewLine); }
+            else { writer.Write(value); }
             writer.Close();
             sw.Write(value);
         }
@@ -159,7 +155,17 @@
                 throw new InvalidOperationException("Please use SetLogText(string value)");
             }
         }
-
+        public void CreateNewLog(bool delete)
+        {
+            if (delete)
+            {
+                FileInfo fi = new FileInfo(LOG_PATH);
+                if (fi.Exists)
+                    fi.Delete();
+            }
+            Log.WriteLine("{0} created on {1}", LoggingConstants.AppLogFile, DateTime.Now.ToString());
+            Log.WriteLine("{0} version: {1} {2} build", LoggingConstants.AppName, LoggingConstants.AppVersion, LoggingConstants.AppBuild);
+        }
         public void Clear()
         {
             Clear(false);

 

  ViewVC Help
Powered by ViewVC 1.1.22