终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

68 regels
1.8 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace BPASmartClient.Message
  8. {
  9. public class MessageLog
  10. {
  11. private volatile static MessageLog _Instance;
  12. public static MessageLog GetInstance => _Instance ?? (_Instance = new MessageLog());
  13. private MessageLog() { }
  14. #region 普通消息日志
  15. /// <summary>
  16. /// 日志显示委托
  17. /// </summary>
  18. public Action<string> InfoNotify { get; set; }
  19. /// <summary>
  20. /// 日志信息
  21. /// </summary>
  22. public string LogInfo { get; set; } = string.Empty;
  23. /// <summary>
  24. /// 普通日志输出
  25. /// </summary>
  26. /// <param name="info"></param>
  27. public void Show(string info)
  28. {
  29. Debug.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")}:{info}");
  30. LogInfo = $"{DateTime.Now.ToString("HH:mm:ss")}:{info} \n\r {LogInfo}";
  31. if (InfoNotify != null) InfoNotify(info);
  32. }
  33. #endregion
  34. #region 异常消息日志
  35. /// <summary>
  36. /// 异常日志委托
  37. /// </summary>
  38. public Action<string> ExInfoNotify { get; set; }
  39. /// <summary>
  40. /// 异常日志信息
  41. /// </summary>
  42. public string ExLogInfo { get; set; } = string.Empty;
  43. /// <summary>
  44. /// 异常日志输出
  45. /// </summary>
  46. /// <param name="info"></param>
  47. public void ShowEx(string info)
  48. {
  49. Debug.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")}:{info}");
  50. ExLogInfo = $"{DateTime.Now.ToString("HH:mm:ss")}:{info} \n\r {ExLogInfo}";
  51. if (ExInfoNotify != null) ExInfoNotify(info);
  52. }
  53. #endregion
  54. }
  55. }