-
-
Save borrrden/b9efd0581b4cdceed40c to your computer and use it in GitHub Desktop.
An adapter for sending Couchbase Lite logs to log4net
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; | |
using Couchbase.Lite.Util; | |
using log4net; | |
namespace Couchbase.Lite.Logger | |
{ | |
// Use like this -> Couchbase.Lite.Util.Log.SetLogger(new Log4NetLogger()) | |
public sealed class Log4NetLogger : ILogger | |
{ | |
private readonly ILog _internalLogger = LogManager.GetLogger("Couchbase"); | |
#region ILogger | |
public void V (string tag, string msg) | |
{ | |
_internalLogger.InfoFormat ("{0}: {1}", tag, msg); | |
} | |
public void V (string tag, string msg, Exception tr) | |
{ | |
_internalLogger.Info (String.Format ("{0}: {1}", tag, msg), tr); | |
} | |
public void V (string tag, string format, params object[] args) | |
{ | |
var realFormat = String.Format("{0}: {1}", tag, format); | |
_internalLogger.InfoFormat(realFormat, args); | |
} | |
public void D (string tag, string msg) | |
{ | |
_internalLogger.DebugFormat ("{0}: {1}", tag, msg); | |
} | |
public void D (string tag, string msg, Exception tr) | |
{ | |
_internalLogger.Debug (String.Format ("{0}: {1}", tag, msg), tr); | |
} | |
public void D (string tag, string format, params object[] args) | |
{ | |
var realFormat = String.Format("{0}: {1}", tag, format); | |
_internalLogger.DebugFormat(realFormat, args); | |
} | |
public void I (string tag, string msg) | |
{ | |
_internalLogger.InfoFormat ("{0}: {1}", tag, msg); | |
} | |
public void I (string tag, string msg, Exception tr) | |
{ | |
_internalLogger.Info (String.Format ("{0}: {1}", tag, msg), tr); | |
} | |
public void I (string tag, string format, params object[] args) | |
{ | |
var realFormat = String.Format("{0}: {1}", tag, format); | |
_internalLogger.InfoFormat(realFormat, args); | |
} | |
public void W (string tag, string msg) | |
{ | |
_internalLogger.WarnFormat ("{0}: {1}", tag, msg); | |
} | |
public void W (string tag, Exception tr) | |
{ | |
_internalLogger.Warn (tag, tr); | |
} | |
public void W (string tag, string msg, Exception tr) | |
{ | |
_internalLogger.Warn (String.Format ("{0}: {1}", tag, msg), tr); | |
} | |
public void W (string tag, string format, params object[] args) | |
{ | |
var realFormat = String.Format("{0}: {1}", tag, format); | |
_internalLogger.WarnFormat(realFormat, args); | |
} | |
public void E (string tag, string msg) | |
{ | |
_internalLogger.ErrorFormat ("{0}: {1}", tag, msg); | |
} | |
public void E (string tag, string msg, Exception tr) | |
{ | |
_internalLogger.Error (String.Format ("{0}: {1}", tag, msg), tr); | |
} | |
public void E (string tag, string format, params object[] args) | |
{ | |
var realFormat = String.Format("{0}: {1}", tag, format); | |
_internalLogger.ErrorFormat(realFormat, args); | |
} | |
#endregion | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment