Created
April 24, 2016 14:05
-
-
Save moswald/d782bcbde0a8b63d871a70d28fb150ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public class SplatToSerilogLogger : Splat.ILogger | |
{ | |
public Serilog.ILogger Serilog { get; set; } = global::Serilog.Log.Logger; | |
public void Write(string message, Splat.LogLevel logLevel) | |
{ | |
if ((int)logLevel >= (int)Level) | |
{ | |
switch (logLevel) | |
{ | |
case Splat.LogLevel.Debug: | |
Serilog.Debug(message); | |
break; | |
case Splat.LogLevel.Info: | |
Serilog.Information(message); | |
break; | |
case Splat.LogLevel.Warn: | |
Serilog.Warning(message); | |
break; | |
case Splat.LogLevel.Error: | |
Serilog.Error(message); | |
break; | |
case Splat.LogLevel.Fatal: | |
Serilog.Fatal(message); | |
break; | |
default: | |
throw new ArgumentOutOfRangeException(nameof(logLevel), logLevel, null); | |
} | |
} | |
} | |
public Splat.LogLevel Level { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment