Support for creating log path and having no log file

This commit is contained in:
2014-05-16 14:13:39 -04:00
parent 91dcbf5116
commit 83f6aaaf61

View File

@@ -63,6 +63,11 @@ namespace Common.Debug
{
_echoToConsole = echoToConsole;
if (!Directory.Exists(logPath))
Directory.CreateDirectory(logPath);
if (!string.IsNullOrEmpty(logPath))
{
// Use the file name template build the base file name
_mainFileName = string.Format(_fileNameTemplate, rootName, uniqueId);
@@ -87,6 +92,7 @@ namespace Common.Debug
// Setup the debug listener
Trace.Listeners.Add(_traceListener);
}
_initialized = true;
@@ -103,6 +109,8 @@ namespace Common.Debug
// Flush the trace
Trace.Flush();
if (_traceListener != null)
{
// Remove the listener
Trace.Listeners.Remove(_traceListener);
@@ -110,6 +118,7 @@ namespace Common.Debug
_traceListener.Close();
_traceListener.Dispose();
_traceListener = null;
}
// Close the trace
Trace.Close();