DebugTrace.cs 911 B

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using System.Diagnostics;
  3. using Cirrious.CrossCore.Platform;
  4. namespace Xamarin_Insights.Android
  5. {
  6. public class DebugTrace : IMvxTrace
  7. {
  8. public void Trace(MvxTraceLevel level, string tag, Func<string> message)
  9. {
  10. Debug.WriteLine(tag + ":" + level + ":" + message());
  11. }
  12. public void Trace(MvxTraceLevel level, string tag, string message)
  13. {
  14. Debug.WriteLine(tag + ":" + level + ":" + message);
  15. }
  16. public void Trace(MvxTraceLevel level, string tag, string message, params object[] args)
  17. {
  18. try
  19. {
  20. Debug.WriteLine(string.Format(tag + ":" + level + ":" + message, args));
  21. }
  22. catch (FormatException)
  23. {
  24. Trace(MvxTraceLevel.Error, tag, "Exception during trace of {0} {1}", level, message);
  25. }
  26. }
  27. }
  28. }