/// <summary> /// Simple wrapper around the log4net Error method. /// </summary> /// <param name="exception"></param> /// <param name="messageFormat"></param> /// <param name="args"></param> public override void Error(Exception exception, string messageFormat, params object[] args) { LogMessage msg = new LogMessage(CultureInfo.InvariantCulture, messageFormat, args); #if __ANDROID__ Android.Util.Log.Error(DeclaringType.Name, msg.ToString()); if (exception != null) { Android.Util.Log.Error(DeclaringType.Name, exception.ToString()); } #else Console.WriteLine(string.Format(DebugMsg, "Exception is: " + exception.ToString() + " Message is: " +msg.ToString())); #endif }
private void Queue(LogMessage message) { lock (_lock) { _logBuffer.AppendLine(message.ToString()); if (_logBuffer.Length >= MAX_BUFFER_SIZE) { LogAsync(_logBuffer); _logBuffer = new StringBuilder(); } } }
private void Log(LogLevel level, string message) { string messageFormat = ""; switch (level) { case LogLevel.Error: messageFormat = ErrorMsgFormat; break; case LogLevel.Debug: messageFormat = DebugMsgFormat; break; case LogLevel.Info: case LogLevel.Verbose: default: messageFormat = InfoMsgFormat; break; } string currentTime = DateTime.UtcNow .ToString(DATE_FORMAT); LogMessage msg = new LogMessage(CultureInfo.InvariantCulture, messageFormat, currentTime, message); Queue(msg); }
/// <summary> /// Simple wrapper around the log4net InfoFormat method. /// </summary> /// <param name="message"></param> /// <param name="arguments"></param> public override void InfoFormat(string message, params object[] arguments) { LogMessage msg = new LogMessage(CultureInfo.InvariantCulture, message, arguments); #if __ANDROID__ Android.Util.Log.Info(DeclaringType.Name, msg.ToString()); #else Console.WriteLine(string.Format(InfoMsg, " Message is: " + msg.ToString())); #endif }
/// <summary> /// Simple wrapper around the log4net Debug method. /// </summary> /// <param name="exception"></param> /// <param name="messageFormat"></param> /// <param name="args"></param> public override void Debug(Exception exception, string messageFormat, params object[] args) { LogMessage msg = new LogMessage(CultureInfo.InvariantCulture, messageFormat, args); Console.WriteLine(string.Format(DebugMsg, "Exception is: " + exception.ToString() + " Message is: " +msg.ToString())); }
/// <summary> /// Simple wrapper around the log4net InfoFormat method. /// </summary> /// <param name="message"></param> /// <param name="arguments"></param> public override void InfoFormat(string message, params object[] arguments) { LogMessage msg = new LogMessage(CultureInfo.InvariantCulture, message, arguments); Console.WriteLine(string.Format(InfoMsg, " Message is: " + msg.ToString())); }