From 67b5e9071a6435737151049c89a8a3a0dfce4997 Mon Sep 17 00:00:00 2001 From: Bradley Gannon Date: Mon, 3 Feb 2025 19:00:59 -0500 Subject: [PATCH 1/2] Remove GodotSink and remaining GD.Print calls --- C7/GodotSink.cs | 35 ----------------------------------- C7/LogManager.cs | 4 ---- 2 files changed, 39 deletions(-) delete mode 100644 C7/GodotSink.cs diff --git a/C7/GodotSink.cs b/C7/GodotSink.cs deleted file mode 100644 index 238af1daa..000000000 --- a/C7/GodotSink.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Godot; -using Serilog; -using Serilog.Core; -using Serilog.Events; -using Serilog.Configuration; -using Serilog.Formatting; -using System.IO; - -public partial class GodotSink : ILogEventSink { - private readonly ITextFormatter _formatter; - - public GodotSink(ITextFormatter formatter) { - _formatter = formatter; - } - - public void Emit(LogEvent logEvent) { - var message = string.Empty; - if (_formatter is null) { - message = logEvent.RenderMessage(); - } else { - var writer = new StringWriter(); - _formatter.Format(logEvent, writer); - message = writer.ToString(); - } - GD.Print(message); - } -} - -public static class GodotSinkExtensions { - public static LoggerConfiguration GodotSink( - this LoggerSinkConfiguration loggerConfiguration, - ITextFormatter formatter = null) { - return loggerConfiguration.Sink(new GodotSink(formatter)); - } -} diff --git a/C7/LogManager.cs b/C7/LogManager.cs index a686286ab..b8d9531bd 100644 --- a/C7/LogManager.cs +++ b/C7/LogManager.cs @@ -21,21 +21,17 @@ public override void _Ready() { // Includes all logs of an 'Information' level regardless of namespace, and all logs of // the C7Engine.AI namespace regardless of log level. Log.Logger = new LoggerConfiguration() - // .WriteTo.GodotSink(formatter: consoleTemplate) //Writing to console can slow the game down considerably (see #278). Thus it is disabled by default. .WriteTo.File("log.txt", buffered: true, flushToDiskInterval: TimeSpan.FromMilliseconds(250), fileSizeLimitBytes: 52428800, //50 MB outputTemplate: "[{Level:u3}] {Timestamp:HH:mm:ss} {SourceContext}: {Message:lj} {NewLine}{Exception}") - .Filter.ByIncludingOnly("(@l = 'Fatal' OR @l = 'Error' OR @l = 'Warning' OR @l = 'Information')") //suggested: OR SourceContext like 'C7Engine.AI.%' (insert the namespace you need to debug) .MinimumLevel.Debug() .CreateLogger(); - GD.Print("Hello logger!"); Log.ForContext().Debug("Hello!"); } public override void _Notification(int what) { if (what == ((long)DisplayServer.WindowEvent.CloseRequest)) { - GD.Print("Goodbye logger!"); Log.ForContext().Debug("Goodbye!"); Log.CloseAndFlush(); GetTree().Quit(); From 3632d114843739dcbf8a904d4b62c622e1ed5e17 Mon Sep 17 00:00:00 2001 From: Bradley Gannon Date: Tue, 13 Jan 2026 20:33:22 -0500 Subject: [PATCH 2/2] Remove commented code related to GodotSink --- C7/LogManager.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/C7/LogManager.cs b/C7/LogManager.cs index 333fa7f70..ae46c2639 100644 --- a/C7/LogManager.cs +++ b/C7/LogManager.cs @@ -25,7 +25,6 @@ public override void _Ready() { // filter += " OR SourceContext like 'C7Engine.AI.%'"; // (insert the namespace you need to debug) Log.Logger = new LoggerConfiguration() - // .WriteTo.GodotSink(formatter: consoleTemplate) //Writing to console can slow the game down considerably (see #278). Thus it is disabled by default. .WriteTo.File("log.txt", buffered: true, flushToDiskInterval: TimeSpan.FromMilliseconds(2500), fileSizeLimitBytes: 52428800, //50 MB outputTemplate: "[{Level:u3}] {Timestamp:HH:mm:ss} {SourceContext}: {Message:lj} {NewLine}{Exception}") .Filter.ByIncludingOnly(filter)