mirror of
https://github.com/ZuneDev/Xune.git
synced 2026-07-27 13:13:10 -07:00
Exposed debug-related options to public
This commit is contained in:
@@ -36,6 +36,7 @@ namespace Microsoft.Iris
|
||||
private static bool s_IsRTL = false;
|
||||
private static Dictionary<int, IExternalAnimationInput> s_idToExternalAnimationInput;
|
||||
private static Dictionary<int, IAnimationInputProvider> s_animationProviders;
|
||||
private static Debug.DebugSettings s_debugSettings;
|
||||
|
||||
public static string Name
|
||||
{
|
||||
@@ -135,7 +136,15 @@ namespace Microsoft.Iris
|
||||
get => DllResources.StaticDllResourcesOnly;
|
||||
}
|
||||
|
||||
public static bool IsDebug { get; set; }
|
||||
public static Debug.DebugSettings DebugSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
if (s_debugSettings == null)
|
||||
s_debugSettings = new Debug.DebugSettings();
|
||||
return s_debugSettings;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Initialize(SkiaSharp.SKSurface skSurface, RenderWindowBase renderWindow)
|
||||
{
|
||||
|
||||
@@ -35,17 +35,14 @@ namespace Microsoft.Iris.Debug
|
||||
if (s_isInitialized)
|
||||
return;
|
||||
s_isInitialized = true;
|
||||
//NativeApi.SpInitializeTracing();
|
||||
TraceSettings.Refresh();
|
||||
TraceSettings.ListenForRegistryUpdates();
|
||||
TraceSettings.Current.ListenForRegistryUpdates();
|
||||
}
|
||||
|
||||
public static void Shutdown()
|
||||
{
|
||||
if (!s_isInitialized)
|
||||
return;
|
||||
TraceSettings.StopListeningForRegistryUpdates();
|
||||
//NativeApi.SpUninitializeTracing();
|
||||
TraceSettings.Current.StopListeningForRegistryUpdates();
|
||||
s_isInitialized = false;
|
||||
}
|
||||
|
||||
@@ -112,8 +109,10 @@ namespace Microsoft.Iris.Debug
|
||||
{
|
||||
if (IsCategoryEnabled(cat, levelFlag))
|
||||
{
|
||||
string content = string.Format(format, pars);
|
||||
System.Diagnostics.Debug.WriteLine(BuildLine(content));
|
||||
string line = BuildLine(string.Format(format, pars));
|
||||
System.Diagnostics.Debug.WriteLine(line);
|
||||
if (TraceSettings.Current.DebugTraceToFile)
|
||||
System.IO.File.AppendAllText(TraceSettings.Current.DebugTraceFile, line + Environment.NewLine);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,12 +122,12 @@ namespace Microsoft.Iris.Debug
|
||||
|
||||
public static bool IsCategoryEnabled(TraceCategory cat, byte requestLevel)
|
||||
{
|
||||
return TraceSettings.GetCategoryLevel(cat) >= requestLevel;
|
||||
return TraceSettings.Current.GetCategoryLevel(cat) >= requestLevel;
|
||||
}
|
||||
|
||||
public static void EnableCategory(TraceCategory cat, bool enabled)
|
||||
{
|
||||
TraceSettings.SetCategoryLevel(cat, (byte)(enabled ? 1 : 0));
|
||||
TraceSettings.Current.SetCategoryLevel(cat, (byte)(enabled ? 1 : 0));
|
||||
}
|
||||
|
||||
public static void EnableAllCategories(bool enabled)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
namespace Microsoft.Iris.Debug
|
||||
{
|
||||
internal enum TraceCategory
|
||||
public enum TraceCategory
|
||||
{
|
||||
AnimationRendering = 0,
|
||||
Critical = 1,
|
||||
|
||||
@@ -6,36 +6,46 @@
|
||||
|
||||
using Microsoft.Iris.OS;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Security;
|
||||
|
||||
namespace Microsoft.Iris.Debug
|
||||
{
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
internal static class TraceSettings
|
||||
public class TraceSettings
|
||||
{
|
||||
private static ConcurrentDictionary<TraceCategory, byte> CategoryLevels = new();
|
||||
private static TraceSettings s_instance;
|
||||
private Dictionary<TraceCategory, byte> CategoryLevels = new Dictionary<TraceCategory, byte>();
|
||||
|
||||
private static string s_debugTraceFile;
|
||||
public TraceSettings()
|
||||
{
|
||||
if (s_instance != null)
|
||||
throw new InvalidOperationException("TraceSettings was already initialized. Use TraceSettings.Current.");
|
||||
s_instance = this;
|
||||
|
||||
public static void ListenForRegistryUpdates()
|
||||
if (DebugTraceToFile && System.IO.File.Exists(DebugTraceFile))
|
||||
System.IO.File.Delete(DebugTraceFile);
|
||||
}
|
||||
|
||||
public static TraceSettings Current
|
||||
{
|
||||
get
|
||||
{
|
||||
if (s_instance == null)
|
||||
new TraceSettings();
|
||||
return s_instance;
|
||||
}
|
||||
}
|
||||
|
||||
public void ListenForRegistryUpdates()
|
||||
{
|
||||
}
|
||||
|
||||
public static void StopListeningForRegistryUpdates()
|
||||
public void StopListeningForRegistryUpdates()
|
||||
{
|
||||
}
|
||||
|
||||
public static void Refresh()
|
||||
{
|
||||
s_debugTraceFile = Environment.GetEnvironmentVariable("SPLASH_TRACE_FILE");
|
||||
WriteLinePrefix = string.Empty;
|
||||
SendOutputToDebugger = true;
|
||||
ShowCategories = false;
|
||||
TimedWriteLines = false;
|
||||
}
|
||||
|
||||
public static byte GetCategoryLevel(TraceCategory cat)
|
||||
public byte GetCategoryLevel(TraceCategory cat)
|
||||
{
|
||||
if (CategoryLevels.TryGetValue(cat, out byte level))
|
||||
return level;
|
||||
@@ -43,31 +53,32 @@ namespace Microsoft.Iris.Debug
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void SetCategoryLevel(TraceCategory cat, byte level)
|
||||
public void SetCategoryLevel(TraceCategory cat, byte level)
|
||||
{
|
||||
CategoryLevels.AddOrUpdate(cat, level, UpdateValueFactory);
|
||||
if (CategoryLevels.ContainsKey(cat))
|
||||
CategoryLevels[cat] = level;
|
||||
else
|
||||
CategoryLevels.Add(cat, level);
|
||||
}
|
||||
|
||||
public static bool IsFlagsCategory(TraceCategory cat) => false;
|
||||
public bool IsFlagsCategory(TraceCategory cat) => false;
|
||||
|
||||
private static bool IsExternalCategory(TraceCategory cat) => (uint)cat < 25U;
|
||||
private bool IsExternalCategory(TraceCategory cat) => (uint)cat < 25U;
|
||||
|
||||
private static byte UpdateValueFactory(TraceCategory cat, byte level) => level;
|
||||
public bool SendOutputToDebugger { get; set; } = true;
|
||||
|
||||
public static bool SendOutputToDebugger { get; set; } = true;
|
||||
public bool TimedWriteLines { get; set; } = false;
|
||||
|
||||
public static bool TimedWriteLines { get; set; } = false;
|
||||
public bool ShowCategories { get; set; } = false;
|
||||
|
||||
public static bool ShowCategories { get; set; } = false;
|
||||
public bool AlwaysShowBraces { get; set; }
|
||||
|
||||
public static bool AlwaysShowBraces { get; set; } = false;
|
||||
public string WriteLinePrefix { get; set; } = string.Empty;
|
||||
|
||||
public static string WriteLinePrefix { get; set; } = "";
|
||||
public string RendererWriteLinePrefix { get; set; }
|
||||
|
||||
public static string RendererWriteLinePrefix { get; set; } = "";
|
||||
public bool DebugTraceToFile => !string.IsNullOrEmpty(DebugTraceFile);
|
||||
|
||||
public static bool DebugTraceToFile => !string.IsNullOrEmpty(s_debugTraceFile);
|
||||
|
||||
public static string DebugTraceFile => s_debugTraceFile;
|
||||
public string DebugTraceFile { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace Microsoft.Iris.Queues
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_debugPipe == null && Application.IsDebug)
|
||||
if (_debugPipe == null && Application.DebugSettings.OpenDebugPipe)
|
||||
{
|
||||
_debugPipe = new NamedPipeClientStream(System.Reflection.Assembly.GetExecutingAssembly().FullName);
|
||||
_debugPipe.Connect();
|
||||
@@ -184,7 +184,7 @@ namespace Microsoft.Iris.Queues
|
||||
/// <param name="message"></param>
|
||||
public static void SendDebugMessage(string message)
|
||||
{
|
||||
if (Application.IsDebug && DebugPipe.IsConnected && DebugPipe.CanWrite)
|
||||
if (Application.DebugSettings.OpenDebugPipe && DebugPipe.IsConnected && DebugPipe.CanWrite)
|
||||
{
|
||||
DebugPipe.WriteByte(0x01);
|
||||
byte[] buffer = System.Text.Encoding.Unicode.GetBytes(message);
|
||||
|
||||
@@ -52,6 +52,10 @@ namespace Xune.Wpf
|
||||
|
||||
private void Init()
|
||||
{
|
||||
#if DEBUG
|
||||
Microsoft.Iris.Application.DebugSettings.TraceSettings.DebugTraceFile = @"C:\Users\jjask\Desktop\UIX.Skia.log";
|
||||
#endif
|
||||
|
||||
Microsoft.Iris.Application.Initialize(Surface, IrisWindow);
|
||||
|
||||
string pageUixPath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory,
|
||||
|
||||
Reference in New Issue
Block a user