PageRenderTime 51ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 1ms

/ApplicationLogger/LoggerIO.cs

https://gitlab.com/Willzam/MannCrafted
C# | 38 lines | 36 code | 2 blank | 0 comment | 1 complexity | cb4d3765ddc24ec789c453dadfc4ec49 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace ApplicationLogger
  8. {
  9. public class LoggerIO : ILoggerIO
  10. {
  11. string path = @"C:\Users\Willzam\Desktop\ErrorLogs\MannCraftedLogger.txt"; //Change willzam to admin when moved over to onshore
  12. public void LogError(string errorType, string message, string location)
  13. {
  14. string[] errorMsg = new string[] { DateTime.Now.ToString(), errorType, message, location };
  15. File.AppendAllLines(path, errorMsg);
  16. }
  17. public List<MessageDO> ReadLog()
  18. {
  19. List<MessageDO> lgs = new List<MessageDO>();
  20. string[] log = File.ReadAllLines(path);
  21. for (int i = 0; i < log.Length; i++)
  22. {
  23. MessageDO mes = new MessageDO();
  24. mes.DateTime = log[i];
  25. i++;
  26. mes.ErrorType = log[i];
  27. i++;
  28. mes.ErrorMessage = log[i];
  29. i++;
  30. mes.Layer = log[i];
  31. lgs.Add(mes);
  32. }
  33. return lgs;
  34. }
  35. }
  36. }