Skip to content

Commit

Permalink
Make DebugLogger usable by not stripping Debug.WriteLine
Browse files Browse the repository at this point in the history
Fixes #46, #58
Closes #123
  • Loading branch information
NZSmartie authored and Glenn Watson committed Nov 21, 2018
1 parent caf164c commit ad3bd14
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
20 changes: 20 additions & 0 deletions src/Splat/DebugLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Taken from https://github.com/aspnet/Logging/blob/dev/src/Microsoft.Extensions.Logging.Debug

// We need to define the DEBUG symbol because we want the logger
// to work even when this package is compiled on release. Otherwise,
// the call to Debug.WriteLine will not be in the release binary
#define DEBUG

namespace Splat
{
public class DebugLogger : ILogger
{
public void Write(string message, LogLevel logLevel)
{
if ((int)logLevel < (int)Level) return;
System.Diagnostics.Debug.WriteLine(message);
}

public LogLevel Level { get; set; }
}
}
13 changes: 0 additions & 13 deletions src/Splat/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Globalization;
using System.Text;
using System.Threading;
using System.Diagnostics;
using System.Diagnostics.Contracts;

namespace Splat
Expand Down Expand Up @@ -159,18 +158,6 @@ public class NullLogger : ILogger
public LogLevel Level { get; set; }
}

public class DebugLogger : ILogger
{
public void Write(string message, LogLevel logLevel)
{
if ((int)logLevel < (int)Level) return;
Debug.WriteLine(message);
}

public LogLevel Level { get; set; }
}


/*
* LogHost / Logging Mixin
*/
Expand Down

0 comments on commit ad3bd14

Please sign in to comment.