8 |
using System.Text; |
using System.Text; |
9 |
using System.Windows.Forms; |
using System.Windows.Forms; |
10 |
using System.IO; |
using System.IO; |
11 |
|
using System.Reflection; |
12 |
|
|
13 |
namespace RomCheater.Logging |
namespace RomCheater.Logging |
14 |
{ |
{ |
15 |
public partial class LogWriter : UserControl |
public partial class LogWriter : UserControl |
16 |
{ |
{ |
17 |
private const string LOG_FILE = "RomCheater.log"; |
private static string LOG_PATH = string.Format(@"{0}\{1}", Application.StartupPath, LoggingConstants.AppLogFile); |
|
private static string LOG_PATH = string.Format(@"{0}\{1}", Application.StartupPath, LOG_FILE); |
|
18 |
|
|
19 |
private delegate string OnGetLogText(); |
private delegate string OnGetLogText(); |
20 |
private delegate void OnSetLogText(string value); |
private delegate void OnSetLogText(string value); |
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; } } |
155 |
throw new InvalidOperationException("Please use SetLogText(string value)"); |
throw new InvalidOperationException("Please use SetLogText(string value)"); |
156 |
} |
} |
157 |
} |
} |
158 |
|
public void CreateNewLog(bool delete) |
159 |
|
{ |
160 |
|
if (delete) |
161 |
|
{ |
162 |
|
FileInfo fi = new FileInfo(LOG_PATH); |
163 |
|
if (fi.Exists) |
164 |
|
fi.Delete(); |
165 |
|
} |
166 |
|
Log.WriteLine("{0} created on {1}", LoggingConstants.AppLogFile, DateTime.Now.ToString()); |
167 |
|
Log.WriteLine("{0} version: {1} {2} build", LoggingConstants.AppName, LoggingConstants.AppVersion, LoggingConstants.AppBuild); |
168 |
|
} |
169 |
public void Clear() |
public void Clear() |
170 |
{ |
{ |
171 |
Clear(false); |
Clear(false); |