/[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

revision 18 by william, Wed May 9 08:16:18 2012 UTC revision 22 by william, Wed May 9 08:43:52 2012 UTC
# Line 13  namespace RomCheater.Logging Line 13  namespace RomCheater.Logging
13  {  {
14      public partial class LogWriter : UserControl      public partial class LogWriter : UserControl
15      {      {
16          private const string LOG_FILE = "RomCheater.log";          public const string LOG_FILE = "RomCheater.log";
17          private static string LOG_PATH = string.Format(@"{0}\{1}", Application.StartupPath, LOG_FILE);          private static string LOG_PATH = string.Format(@"{0}\{1}", Application.StartupPath, LOG_FILE);
18    
19          private delegate string OnGetLogText();          private delegate string OnGetLogText();
# Line 42  namespace RomCheater.Logging Line 42  namespace RomCheater.Logging
42              sw = new StreamWriter(ms);              sw = new StreamWriter(ms);
43              sw.AutoFlush = true;              sw.AutoFlush = true;
44              sr = new StreamReader(ms);              sr = new StreamReader(ms);
   
             FileInfo fi = new FileInfo(LOG_PATH);  
             if (fi.Exists)  
                 fi.Delete();  
   
45          }          }
46          private LogStream _Log;          private LogStream _Log;
47          public LogStream Log { get { return _Log; } private set { _Log = value; } }          public LogStream Log { get { return _Log; } private set { _Log = value; } }
# Line 144  namespace RomCheater.Logging Line 139  namespace RomCheater.Logging
139              FileStream fs = new FileStream(LOG_PATH, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);              FileStream fs = new FileStream(LOG_PATH, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
140              StreamWriter writer = new StreamWriter(fs);              StreamWriter writer = new StreamWriter(fs);
141              writer.AutoFlush = true;              writer.AutoFlush = true;
142              writer.Write(value);              if (value == Log.NewLine) { writer.Write(System.Environment.NewLine); }
143                else { writer.Write(value); }
144              writer.Close();              writer.Close();
145              sw.Write(value);              sw.Write(value);
146          }          }
# Line 159  namespace RomCheater.Logging Line 155  namespace RomCheater.Logging
155                  throw new InvalidOperationException("Please use SetLogText(string value)");                  throw new InvalidOperationException("Please use SetLogText(string value)");
156              }              }
157          }          }
158            public void CreateNewLog()
159            {
160                FileInfo fi = new FileInfo(LOG_PATH);
161                if (fi.Exists)
162                    fi.Delete();
163            }
164          public void Clear()          public void Clear()
165          {          {
166              Clear(false);              Clear(false);

Legend:
Removed from v.18  
changed lines
  Added in v.22

  ViewVC Help
Powered by ViewVC 1.1.22