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.
 
 

36 lines
941 B

  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 HBLConsole.Service
  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. /// <summary>
  15. /// 日志显示委托
  16. /// </summary>
  17. public Action<string> InfoNotify { get; set; }
  18. /// <summary>
  19. /// 日志信息
  20. /// </summary>
  21. public string LogInfo { get; set; } = string.Empty;
  22. public void Show(string info)
  23. {
  24. Debug.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")}:{info}");
  25. LogInfo = $"{DateTime.Now.ToString("HH:mm:ss")}:{info} \n\r {LogInfo}";
  26. if (InfoNotify != null) InfoNotify(info);
  27. }
  28. }
  29. }