Log.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. namespace IFramework
  3. {
  4. #pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
  5. public class Log
  6. {
  7. public static bool enable = true;
  8. public static bool enable_L = true;
  9. public static bool enable_W = true;
  10. public static bool enable_E = true;
  11. public static ILoger loger { get; set; }
  12. public static ILogRecorder recorder { get; set; }
  13. static Log()
  14. {
  15. loger = new CSLogger();
  16. }
  17. public static void L(object message, params object[] paras)
  18. {
  19. if (!enable) return;
  20. if (!enable_L) return;
  21. if (loger!=null)
  22. loger.Log(message, paras);
  23. if (recorder!=null)
  24. recorder.Log(message, paras);
  25. }
  26. public static void W(object message, params object[] paras)
  27. {
  28. if (!enable) return;
  29. if (!enable_W) return;
  30. if (loger!=null)
  31. loger.Warn(message, paras);
  32. if (recorder != null)
  33. recorder.Warn(message, paras);
  34. }
  35. public static void E(object message, params object[] paras)
  36. {
  37. if (!enable) return;
  38. if (!enable_E) return;
  39. if (loger != null)
  40. loger.Error( message, paras);
  41. if (recorder != null)
  42. recorder.Log(message, paras);
  43. }
  44. public static void Exception(Exception ex)
  45. {
  46. if (!enable) return;
  47. if (!enable_E) return;
  48. if (loger != null)
  49. loger.Exception(ex);
  50. if (recorder != null)
  51. recorder.Exception(ex);
  52. }
  53. }
  54. #pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
  55. }