LogManager.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. namespace UAS_DXFORM
  7. {
  8. class LogManager
  9. {
  10. public static string LogAddress = SystemInf.LogFolder;
  11. /// <summary>
  12. /// 记录操作
  13. /// </summary>
  14. /// <param name="Message"></param>
  15. public static void DoLog(string Message)
  16. {
  17. try
  18. {
  19. StreamWriter sw = File.AppendText(LogAddress + DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
  20. sw.WriteLine("\n【时间】" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\n");
  21. sw.WriteLine("【消息】" + Message + "\n");
  22. sw.WriteLine("---------------------------------------------------------------------------------------------------------------");
  23. sw.Close();
  24. }
  25. catch (Exception) { }
  26. }
  27. /// <summary>
  28. /// 记录操作
  29. /// </summary>
  30. /// <param name="Message"></param>
  31. public static void DoLog(List<String> Message,string info)
  32. {
  33. try
  34. {
  35. StreamWriter sw = File.AppendText(LogAddress + DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
  36. sw.WriteLine("\n【时间】" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\n");
  37. sw.WriteLine("【消息】" + info + "\n");
  38. foreach (string mes in Message)
  39. {
  40. sw.WriteLine(mes + "\n");
  41. }
  42. //int T = Message.Count;
  43. //for (int i = 0; i < T; i++)
  44. //{
  45. // sw.WriteLine(Message[i].ToString() + "\n");
  46. //}
  47. sw.WriteLine("---------------------------------------------------------------------------------------------------------------");
  48. sw.Close();
  49. }
  50. catch (Exception) { }
  51. }
  52. }
  53. }