mirror of
https://github.com/reactos/reactosdbg.git
synced 2024-11-26 21:20:22 +00:00
a613572873
- Remove the null checks from DockPanel and wrap it in try/catch blocks instead (considering it shouldn't happen) - Use RosDiagnostics.DebugTrace to add debug info now. The app now needs to make correct use of exception handling svn path=/trunk/tools/reactosdbg/; revision=1027
62 lines
2.1 KiB
C#
62 lines
2.1 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Diagnostics;
|
|
using System.Windows.Forms;
|
|
|
|
namespace RosDBG
|
|
{
|
|
static class RosDiagnostics
|
|
{
|
|
public enum TraceType
|
|
{
|
|
Info, Error, Exception
|
|
}
|
|
|
|
static public void SetupLogger()
|
|
{
|
|
try
|
|
{
|
|
if (Convert.ToBoolean(Settings.AppLogging))
|
|
{
|
|
File.Delete(Settings.AppLogFile);
|
|
FileStream traceLogFile = new FileStream(Settings.AppLogFile, FileMode.OpenOrCreate);
|
|
Trace.Listeners.Add(new TextWriterTraceListener(traceLogFile));
|
|
Trace.AutoFlush = true;
|
|
}
|
|
}
|
|
catch (DirectoryNotFoundException)
|
|
{
|
|
MessageBox.Show(String.Format("Logging: {0} does not exist.\n" +
|
|
"Please use the settings dialog to correct this",
|
|
Settings.AppLogFile));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(String.Format("Failed to setup logging. Unexpected error:\n {0}",
|
|
ex.Message));
|
|
}
|
|
}
|
|
|
|
static public void DebugTrace(TraceType type, string msg)
|
|
{
|
|
StackTrace st = new StackTrace(true);
|
|
StackFrame sf = st.GetFrame(1);
|
|
|
|
string typeStr = "";
|
|
switch (type)
|
|
{
|
|
case TraceType.Info: typeStr = "Info"; break;
|
|
case TraceType.Error: typeStr = "Err"; break;
|
|
case TraceType.Exception: typeStr = "Exception"; break;
|
|
}
|
|
|
|
Trace.WriteLine(String.Format("{0, -9} : {1} {2}:{3} {4}",
|
|
typeStr,
|
|
msg,
|
|
sf.GetMethod().Name,
|
|
sf.GetFileName(),
|
|
sf.GetFileLineNumber()));
|
|
}
|
|
}
|
|
}
|