EventLogWriter.cs 762 B

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Aitex.Core.RT.Log;
  6. namespace Aitex.Core.RT.Event
  7. {
  8. class EventLogWriter
  9. {
  10. public void WriteEvent(EventItem ev)
  11. {
  12. if (!string.IsNullOrWhiteSpace(ev.Source))
  13. {
  14. ev.Description = ev.Source + " " + ev.Description;
  15. }
  16. if (ev.Level == EventLevel.Alarm)
  17. LOG.Error(ev.Description.Replace("'", "''"));
  18. else if (ev.Level == EventLevel.Warning)
  19. {
  20. LOG.Warning(ev.Description.Replace("'", "''"));
  21. }
  22. else
  23. {
  24. LOG.Info(ev.Description.Replace("'", "''"));
  25. }
  26. }
  27. }
  28. }