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 93ad8817..ae46c263 100644 --- a/C7/LogManager.cs +++ b/C7/LogManager.cs @@ -21,24 +21,21 @@ 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. string filter = "(@l = 'Fatal' OR @l = 'Error' OR @l = 'Warning' OR @l = 'Information')"; - // suggested: + // suggested: // 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) .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();