diff --git a/C7/GodotSink.cs b/C7/GodotSink.cs deleted file mode 100644 index 238af1da..00000000 --- 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 a686286a..b8d9531b 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();