From 8a349b2945a9625e27b58c2f46f345613e64e6cb Mon Sep 17 00:00:00 2001 From: Mark Wilson <23439518+wlsnmrk@users.noreply.github.com> Date: Mon, 3 Feb 2025 14:12:33 -0500 Subject: [PATCH] doc: explain adding DefaultTraceListener for VS --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index ad42e1c..24f1191 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,32 @@ below for details. The package provides one additional writer type, `TestWriter`, which may be useful for testing your code without mocking `ILog` (see below). +### Using `TraceWriter` + +To see `TraceWriter`'s output from a Godot application in Visual Studio's +Output pane, add a `DefaultTraceListener` to the system's list of `Trace` +listeners somewhere near your entry point: + +```csharp +using System.Diagnostics; + +public class MyGodotApp : Node +{ + public override void _Ready() + { + Trace.Listeners.Add(new DefaultTraceListener()); + } +} +``` + +This step is necessary with [GoDotTest] test suites as well as games (or any +other Godot-based applications). + +> [!TIP] +> This step is unnecessary if you are running or debugging in Visual Studio +> Code, so you may want to guard adding `DefaultTraceListener` with a +> command-line flag. + ### Using `FileWriter` `FileWriter` provides two static `Instance()` methods for obtaining references @@ -267,3 +293,4 @@ public class MyClassTest [Chickensoft.Log]: https://www.nuget.org/packages/Chickensoft.Log [log-godot]: https://github.com/chickensoft-games/Log.Godot +[GoDotTest]: https://github.com/chickensoft-games/GoDotTest