Log.cs 927 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Base
  4. {
  5. public static class Log
  6. {
  7. private static readonly ILog globalLog = new NLogAdapter();
  8. public static Dictionary<long, Action<LogType, string>> Callback { get; } = new Dictionary<long, Action<LogType, string>>();
  9. private static void OnCallback(LogType type, string message)
  10. {
  11. foreach (var action in Callback.Values)
  12. {
  13. action(type, message);
  14. }
  15. }
  16. public static void Warning(string message)
  17. {
  18. globalLog.Warning(message);
  19. OnCallback(LogType.Warning, message);
  20. }
  21. public static void Info(string message)
  22. {
  23. globalLog.Info(message);
  24. OnCallback(LogType.Info, message);
  25. }
  26. public static void Debug(string message)
  27. {
  28. globalLog.Debug(message);
  29. OnCallback(LogType.Debug, message);
  30. }
  31. public static void Error(string message)
  32. {
  33. globalLog.Error(message);
  34. OnCallback(LogType.Error, message);
  35. }
  36. }
  37. }