Skip to content

Commit

Permalink
Merge pull request #7 from chickensoft-games/doc/explain-tracewriter
Browse files Browse the repository at this point in the history
doc: update readme to explain adding `DefaultTraceListener` for Visual Studio
  • Loading branch information
wlsnmrk authored Feb 3, 2025
2 parents 1b32a1e + 8a349b2 commit 502df6c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 502df6c

Please sign in to comment.