mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-23 01:15:09 +00:00
Configured Trace log file via app.config file
This commit is contained in:
@@ -12,7 +12,11 @@
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
|
||||
</startup>
|
||||
<system.diagnostics>
|
||||
<trace autoflush="true"/>
|
||||
<trace autoflush="true">
|
||||
<listeners>
|
||||
<add name="TraceLogger" type="System.Diagnostics.TextWriterTraceListener" initializeData="trace.log"/>
|
||||
</listeners>
|
||||
</trace>
|
||||
</system.diagnostics>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
|
||||
@@ -19,7 +19,6 @@ namespace PckStudio.Internal
|
||||
|
||||
internal static void Initialize()
|
||||
{
|
||||
Profiler.Configure(Debug.Listeners[0]);
|
||||
Profiler.Start();
|
||||
{
|
||||
_entityImages ??= Resources.entities_sheet.SplitHorizontal(32).ToArray();
|
||||
|
||||
@@ -28,19 +28,12 @@ namespace PckStudio.Internal
|
||||
internal static class Profiler
|
||||
{
|
||||
private static Stopwatch _stopwatch = new Stopwatch();
|
||||
private static TraceListener _listener;
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
internal static void Configure(TraceListener listener)
|
||||
{
|
||||
_listener = listener;
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
internal static void Start([CallerMemberName] string caller = default!, [CallerFilePath] string source = default!, [CallerLineNumber] int line = default!)
|
||||
{
|
||||
_listener?.WriteLine($"Stopwatch starts", category: nameof(Profiler));
|
||||
_listener?.WriteLine($"{source}@{caller}:{line}", category: nameof(Profiler));
|
||||
Debug.WriteLine($"Stopwatch starts", category: nameof(Profiler));
|
||||
Debug.WriteLine($"{source}@{caller}:{line}", category: nameof(Profiler));
|
||||
_stopwatch.Restart();
|
||||
}
|
||||
|
||||
@@ -48,7 +41,7 @@ namespace PckStudio.Internal
|
||||
internal static void Stop([CallerMemberName] string caller = default!, [CallerFilePath] string source = default!, [CallerLineNumber] int line = default!)
|
||||
{
|
||||
_stopwatch.Stop();
|
||||
_listener?.WriteLine($"{caller} took {_stopwatch.ElapsedMilliseconds}ms", category: nameof(Profiler));
|
||||
Debug.WriteLine($"{caller} took {_stopwatch.ElapsedMilliseconds}ms", category: nameof(Profiler));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,9 +23,8 @@ namespace PckStudio
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
using var traceFile = File.OpenWrite(Path.Combine(Application.StartupPath, "tarce.log"));
|
||||
Trace.Listeners.Add(new TextWriterTraceListener(traceFile));
|
||||
ApplicationScope.Initialize();
|
||||
Trace.TraceInformation("Startup");
|
||||
RPC.Initialize();
|
||||
MainInstance = new MainForm();
|
||||
if (args.Length > 0 && File.Exists(args[0]) && args[0].EndsWith(".pck"))
|
||||
|
||||
Reference in New Issue
Block a user