Skip to content

Commit

Permalink
preserve the debug logger (#1326)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleibow authored Jun 15, 2021
1 parent 59d330a commit 5ee5051
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
19 changes: 19 additions & 0 deletions src/Core/src/Hosting/Internal/FallbackLogging.Debug.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
}
6 changes: 3 additions & 3 deletions src/Core/src/Hosting/Internal/FallbackLogging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Microsoft.Maui.Hosting.Internal
{
class FallbackLoggerFactory : ILoggerFactory
partial class FallbackLoggerFactory : ILoggerFactory
{
public void AddProvider(ILoggerProvider provider) { }

Expand All @@ -15,7 +15,7 @@ public ILogger CreateLogger(string categoryName) =>

public void Dispose() { }

class FallbackLogger : ILogger
partial class FallbackLogger : ILogger
{
private string _categoryName;

Expand Down Expand Up @@ -46,7 +46,7 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
if (exception != null)
message += Environment.NewLine + Environment.NewLine + exception;

Debug.WriteLine(message, category: _categoryName);
DebugWriteLine(message);
}
}

Expand Down

0 comments on commit 5ee5051

Please sign in to comment.