You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1010 B

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  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. using IPA.Logging;
  8. namespace IPA.Logging.Printers
  9. {
  10. class GlobalLogFilePrinter : GZFilePrinter
  11. {
  12. public override Logger.LogLevel Filter { get; set; } = Logger.LogLevel.All;
  13. public override void Print(IPA.Logging.Logger.Level level, DateTime time, string logName, string message)
  14. {
  15. foreach (var line in message.Split(new string[] { "\n", Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
  16. fileWriter.WriteLine(string.Format(Logger.LogFormat, line, logName, time, level.ToString().ToUpper()));
  17. }
  18. protected override FileInfo GetFileInfo()
  19. {
  20. var logsDir = new DirectoryInfo("Logs");
  21. logsDir.Create();
  22. var finfo = new FileInfo(Path.Combine(logsDir.FullName, $"{DateTime.Now:yyyy.MM.dd.HH.mm}.log"));
  23. return finfo;
  24. }
  25. }
  26. }