LogHelper.cs 867 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace X2D1NoRefTaskServer
  7. {
  8. public static class LogHelper
  9. {
  10. public static Action<LogInfo> Logger;
  11. public static void Info(string msg)
  12. {
  13. Serilog.Log.Information(msg);
  14. Logger?.Invoke(new LogInfo() { LogType = EnumLogType.Info, Msg = msg });
  15. }
  16. public static void Warning(string msg, Exception ex = null)
  17. {
  18. Serilog.Log.Warning(ex, msg);
  19. Logger?.Invoke(new LogInfo() { LogType = EnumLogType.Warning, Msg = msg });
  20. }
  21. public static void Error(string msg, Exception ex = null)
  22. {
  23. Serilog.Log.Error(ex, msg);
  24. Logger?.Invoke(new LogInfo() { LogType = EnumLogType.Error, Msg = msg });
  25. }
  26. }
  27. }