log.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using System.Collections.Generic;
  2. namespace Test
  3. {
  4. public static class Log
  5. {
  6. private static LogManager logManager;
  7. static Log()
  8. {
  9. LogManager.Init();
  10. logManager = new LogManager();
  11. }
  12. /// <summary>
  13. /// 写文件类型
  14. /// </summary>
  15. /// <param name="logType"></param>
  16. /// <param name="logFile"></param>
  17. /// <param name="msg"></param>
  18. public static void WriteLog(LogType logType, LogFile logFile, string msg)
  19. {
  20. try
  21. {
  22. logManager.WriteLog(logType, logFile, msg);
  23. }
  24. catch
  25. {
  26. }
  27. }
  28. /// <summary>
  29. /// 文件类型为null
  30. /// </summary>
  31. /// <param name="logType"></param>
  32. /// <param name="msg"></param>
  33. public static void WriteLog(LogType logType, string msg)
  34. {
  35. try
  36. {
  37. logManager.WriteLog(logType, string.Empty, msg);
  38. }
  39. catch
  40. {
  41. }
  42. }
  43. /// <summary>
  44. /// 数据库异常的标志位
  45. /// 0表示update,1表示insert
  46. /// </summary>
  47. /// <param name="logType"></param>
  48. /// <param name="status"></param>
  49. /// <param name="msg"></param>
  50. public static void WriteLog(LogType logType, string status, string msg)
  51. {
  52. try
  53. {
  54. logManager.WriteLog(logType, status, msg);
  55. }
  56. catch
  57. {
  58. }
  59. }
  60. /// <summary>
  61. /// 读日志文件
  62. /// </summary>
  63. /// <param name="sqlStatus"></param>
  64. /// <param name="sqlMsg"></param>
  65. /// <param name="count"></param>
  66. public static List<string> ReadLog()
  67. {
  68. List<string> digitList = null;
  69. try
  70. {
  71. digitList = logManager.ReadLog();
  72. }
  73. catch { }
  74. return digitList;
  75. }
  76. public static void WriteCredence(string msg)
  77. {
  78. try
  79. {
  80. logManager.WriteCredence(msg);
  81. }
  82. catch { }
  83. }
  84. public static void WriteData(string name, string msg)
  85. {
  86. try
  87. {
  88. logManager.WriteData(name, msg);
  89. }
  90. catch { }
  91. }
  92. }
  93. }