Add secondary Trace callback

This commit is contained in:
Yoshi Askharoun
2024-02-16 20:39:27 -06:00
parent 42c3597646
commit 3bd3531f44
2 changed files with 9 additions and 2 deletions
+4 -1
View File
@@ -113,7 +113,10 @@ namespace Microsoft.Iris.Debug
if (IsCategoryEnabled(cat, levelFlag)) if (IsCategoryEnabled(cat, levelFlag))
{ {
string content = string.Format(format, pars); string content = string.Format(format, pars);
System.Diagnostics.Debug.WriteLine(BuildLine(content)); var line = BuildLine(content);
System.Diagnostics.Debug.WriteLine(line);
TraceSettings.Current.FireWriteCallbacks(line);
} }
} }
+5 -1
View File
@@ -15,7 +15,7 @@ namespace Microsoft.Iris.Debug
public class TraceSettings public class TraceSettings
{ {
private static TraceSettings s_instance; private static TraceSettings s_instance;
private Dictionary<TraceCategory, byte> CategoryLevels = new Dictionary<TraceCategory, byte>(); private Dictionary<TraceCategory, byte> CategoryLevels = new();
private string s_debugTraceFile; private string s_debugTraceFile;
public TraceSettings() public TraceSettings()
@@ -90,5 +90,9 @@ namespace Microsoft.Iris.Debug
public bool DebugTraceToFile => !string.IsNullOrEmpty(s_debugTraceFile); public bool DebugTraceToFile => !string.IsNullOrEmpty(s_debugTraceFile);
public string DebugTraceFile => s_debugTraceFile; public string DebugTraceFile => s_debugTraceFile;
public event Action<string> OnWriteLine;
internal void FireWriteCallbacks(string line) => OnWriteLine?.Invoke(line);
} }
} }