Created
September 19, 2014 22:24
-
-
Save TimMurphy/7f79c2025fc14bb41c47 to your computer and use it in GitHub Desktop.
Anotar.Custom implementation for LibLog
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
public class LibLogLogger | |
{ | |
private readonly ILog Logger; | |
public LibLogLogger(ILog logger) | |
{ | |
Logger = logger; | |
} | |
public bool IsDebugEnabled | |
{ | |
get { throw new NotSupportedException(); } | |
} | |
public bool IsInformationEnabled | |
{ | |
get { throw new NotSupportedException(); } | |
} | |
public bool IsWarningEnabled | |
{ | |
get { throw new NotSupportedException(); } | |
} | |
public bool IsErrorEnabled | |
{ | |
get { throw new NotSupportedException(); } | |
} | |
public bool IsFatalEnabled | |
{ | |
get { throw new NotSupportedException(); } | |
} | |
public void Debug(string format, params object[] args) | |
{ | |
LogFormat(LogLevel.Debug, format, args); | |
} | |
public void Debug(Exception exception, string format, params object[] args) | |
{ | |
LogException(LogLevel.Debug, exception, format, args); | |
} | |
public void Information(string format, params object[] args) | |
{ | |
LogFormat(LogLevel.Info, format, args); | |
} | |
public void Information(Exception exception, string format, params object[] args) | |
{ | |
LogException(LogLevel.Info, exception, format, args); | |
} | |
public void Warning(string format, params object[] args) | |
{ | |
LogFormat(LogLevel.Warn, format, args); | |
} | |
public void Warning(Exception exception, string format, params object[] args) | |
{ | |
LogException(LogLevel.Warn, exception, format, args); | |
} | |
public void Error(string format, params object[] args) | |
{ | |
LogFormat(LogLevel.Error, format, args); | |
} | |
public void Error(Exception exception, string format, params object[] args) | |
{ | |
LogException(LogLevel.Error, exception, format, args); | |
} | |
public void Fatal(string format, params object[] args) | |
{ | |
LogFormat(LogLevel.Fatal, format, args); | |
} | |
public void Fatal(Exception exception, string format, params object[] args) | |
{ | |
LogException(LogLevel.Fatal, exception, format, args); | |
} | |
private void LogFormat(LogLevel logLevel, string format, object[] args) | |
{ | |
Logger.Log(logLevel, () => string.Format(CultureInfo.InvariantCulture, format, args)); | |
} | |
private void LogException(LogLevel logLevel, Exception exception, string format, object[] args) | |
{ | |
Logger.Log(logLevel, () => string.Format(CultureInfo.InvariantCulture, format, args), exception); | |
} | |
} |
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
public class LoggerFactory | |
{ | |
public static LibLogLogger GetLogger<T>() | |
{ | |
return new LibLogLogger(LogProvider.For<T>()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment