mirror of
https://github.com/ckaczor/Common.git
synced 2026-02-16 10:58:34 -05:00
Support for creating log path and having no log file
This commit is contained in:
@@ -63,6 +63,11 @@ namespace Common.Debug
|
|||||||
{
|
{
|
||||||
_echoToConsole = echoToConsole;
|
_echoToConsole = echoToConsole;
|
||||||
|
|
||||||
|
if (!Directory.Exists(logPath))
|
||||||
|
Directory.CreateDirectory(logPath);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(logPath))
|
||||||
|
{
|
||||||
// Use the file name template build the base file name
|
// Use the file name template build the base file name
|
||||||
_mainFileName = string.Format(_fileNameTemplate, rootName, uniqueId);
|
_mainFileName = string.Format(_fileNameTemplate, rootName, uniqueId);
|
||||||
|
|
||||||
@@ -87,6 +92,7 @@ namespace Common.Debug
|
|||||||
|
|
||||||
// Setup the debug listener
|
// Setup the debug listener
|
||||||
Trace.Listeners.Add(_traceListener);
|
Trace.Listeners.Add(_traceListener);
|
||||||
|
}
|
||||||
|
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
|
|
||||||
@@ -103,6 +109,8 @@ namespace Common.Debug
|
|||||||
// Flush the trace
|
// Flush the trace
|
||||||
Trace.Flush();
|
Trace.Flush();
|
||||||
|
|
||||||
|
if (_traceListener != null)
|
||||||
|
{
|
||||||
// Remove the listener
|
// Remove the listener
|
||||||
Trace.Listeners.Remove(_traceListener);
|
Trace.Listeners.Remove(_traceListener);
|
||||||
|
|
||||||
@@ -110,6 +118,7 @@ namespace Common.Debug
|
|||||||
_traceListener.Close();
|
_traceListener.Close();
|
||||||
_traceListener.Dispose();
|
_traceListener.Dispose();
|
||||||
_traceListener = null;
|
_traceListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
// Close the trace
|
// Close the trace
|
||||||
Trace.Close();
|
Trace.Close();
|
||||||
|
|||||||
Reference in New Issue
Block a user