From 5ee5051138dc536dff179f6e2591b218d560cd46 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Tue, 15 Jun 2021 21:00:10 +0200 Subject: [PATCH] preserve the debug logger (#1326) --- .../Hosting/Internal/FallbackLogging.Debug.cs | 19 +++++++++++++++++++ .../src/Hosting/Internal/FallbackLogging.cs | 6 +++--- 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 src/Core/src/Hosting/Internal/FallbackLogging.Debug.cs diff --git a/src/Core/src/Hosting/Internal/FallbackLogging.Debug.cs b/src/Core/src/Hosting/Internal/FallbackLogging.Debug.cs new file mode 100644 index 000000000000..2b3d286981ba --- /dev/null +++ b/src/Core/src/Hosting/Internal/FallbackLogging.Debug.cs @@ -0,0 +1,19 @@ +#nullable enable +#define DEBUG + +using System.Diagnostics; +using Microsoft.Extensions.Logging; + +namespace Microsoft.Maui.Hosting.Internal +{ + partial class FallbackLoggerFactory + { + partial class FallbackLogger : ILogger + { + void DebugWriteLine(string message) + { + Debug.WriteLine(message, category: _categoryName); + } + } + } +} \ No newline at end of file diff --git a/src/Core/src/Hosting/Internal/FallbackLogging.cs b/src/Core/src/Hosting/Internal/FallbackLogging.cs index 99b3f33abeff..c836fbe08bbe 100644 --- a/src/Core/src/Hosting/Internal/FallbackLogging.cs +++ b/src/Core/src/Hosting/Internal/FallbackLogging.cs @@ -6,7 +6,7 @@ namespace Microsoft.Maui.Hosting.Internal { - class FallbackLoggerFactory : ILoggerFactory + partial class FallbackLoggerFactory : ILoggerFactory { public void AddProvider(ILoggerProvider provider) { } @@ -15,7 +15,7 @@ public ILogger CreateLogger(string categoryName) => public void Dispose() { } - class FallbackLogger : ILogger + partial class FallbackLogger : ILogger { private string _categoryName; @@ -46,7 +46,7 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except if (exception != null) message += Environment.NewLine + Environment.NewLine + exception; - Debug.WriteLine(message, category: _categoryName); + DebugWriteLine(message); } }