Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace GoDotLog with Chickensoft.Log #130

Merged

Conversation

wlsnmrk
Copy link
Contributor

@wlsnmrk wlsnmrk commented Feb 3, 2025

Updates GoDotTest to use the new Chickensoft.Log package instead of GoDotLog.

  • Bump .NET to v8
  • Replace PackageReference GoDotLog -> Chickensoft.Log
  • Replace using statements GoDotLog -> Chickensoft.Log
  • Replace GDLog(name) with Log(name, new TraceWriter()) to support output in VSCode, VS, and Godot
  • Add logic to GoTest.RunTests() to optionally add a DefaultTraceListener to Trace.Listeners, to enable echoing output to Visual Studio's Output pane. This logic also removes the DefaultTraceListener in a finally block, in case multiple calls to GoTest.RunTests() take place (as in the test suite for this package). The option to add DefaultTraceListener is enabled disabled by default.
  • Add a TraceListenerManager class implementing IDisposable that optionally adds a DefaultTraceListener to the global trace-listeners collection in its constructor, and removes the listener when disposed. Add a TraceListenerManager in a using to GoTest.RunTests() to optionally add a DefaultTraceListener before running tests and remove it after.
  • Add a new command-line switch that prevents enables the DefaultTraceListener. VSCode gets doubled output if DefaultTraceListener is added, presumably from listening to both Trace and to Godot's console output of the same Trace, so this option should be enabled skipped in VSCode settings to avoid the doubled output. (Godot outputs Trace to console by registering its own listener and then echoing that data to console.)
  • Add Visual-Studio launch configuration files. The test-project configuration uses the new command-line switch to enable the DefaultTraceListener and thereby provide output when debugging in Visual Studio.
  • Update README to include launch profiles for Visual Studio and a description of the new command-line switch.

WIth these changes, GoDotTest output appears in Godot, Visual Studio, and VSCode:
Screenshot 2025-02-03 150219
Screenshot 2025-02-03 150242
Screenshot 2025-02-03 150256

* Bump .NET to v8
* Replace PackageReference to GoDotLog with new
  Chickensoft.Log
* Replace usings GoDotLog -> Chickensoft.Log
* Replace GDLog with Log and a TraceWriter to
  support output in VSCode, VS, and Godot
* Add logic to GoTest to optionally add a
  DefaultTraceListener before running tests and
  to always remove it as the last step of
  execution (prevents multiple
  DefaultTraceListeners if multiple calls to
  GoTest.RunTests() happen)
* Add logic to TestEnvironment for a command-line
  option that skips adding the
  DefaultTraceListener (useful for VSCode, which
  picks up Trace output without the
  DefaultTraceListener)
@wlsnmrk wlsnmrk force-pushed the refactor/use-chickensoft-log branch from ddf08b5 to 449e7b0 Compare February 3, 2025 20:45
Created a TraceListenerManager that optionally adds the
DefaultTraceListener to the system's list of Trace listeners. The
manager is disposable and uses its Dispose() behavior to remove the
listener if one was added. By putting the manager in a using, we
obtain reliable removal of the DefaultTraceListener without using a
try-finally block.
* Added config instructions for Visual Studio
* Added an explanation of the new CLI argument
  --listen-trace
@wlsnmrk wlsnmrk force-pushed the refactor/use-chickensoft-log branch from c25f540 to 0a541de Compare February 6, 2025 19:21
@wlsnmrk wlsnmrk merged commit ae9a7d1 into chickensoft-games:main Feb 8, 2025
4 checks passed
@wlsnmrk wlsnmrk deleted the refactor/use-chickensoft-log branch February 8, 2025 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants