Logger.cs 1022 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System.IO;
  2. using System.Text.RegularExpressions;
  3. namespace GCHR.Control
  4. {
  5. public class Logger
  6. {
  7. public static string ConfigDatei = "config\\gchr.xml";
  8. public static string LogDatei
  9. {
  10. get { return "logs\\" + Regex.Match(ConfigDatei, @"\w*\.xml$") + ".log"; }
  11. }
  12. public static string ExportLog = LogDatei;
  13. public static void Info(string message)
  14. {
  15. lock(LogDatei)
  16. {
  17. Log(message, LogDatei);
  18. }
  19. }
  20. public static void Progress(string message)
  21. {
  22. lock(ExportLog)
  23. {
  24. Log(message, ExportLog);
  25. }
  26. }
  27. private static void Log(string message, string datei)
  28. {
  29. using (var sw = new StreamWriter(datei, true))
  30. {
  31. sw.WriteLine(message);
  32. }
  33. }
  34. public static bool DateiExistiert { get { return File.Exists(LogDatei); }
  35. }
  36. }
  37. }