EventLogSubscriptionLogWriter.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. namespace Wayne.Lib.Log
  2. {
  3. /// <summary>
  4. /// A log writer that writes to the EventLog Publisher/subscriber interface.
  5. /// </summary>
  6. internal class EventLogSubscriptionLogWriter : LogWriter
  7. {
  8. #region Fields
  9. private string subscriberId;
  10. private LogConfigEventLogStorageType storageType;
  11. #endregion
  12. #region Construction
  13. public EventLogSubscriptionLogWriter(string logName, LogConfigEventLogSubscriptionOutput output)
  14. : base(logName)
  15. {
  16. subscriberId = output.SubscriberId;
  17. storageType = output.StorageType;
  18. }
  19. #endregion
  20. #region Properties
  21. /// <summary>
  22. /// The id of the subscriber that should pick up the events from this log writer.
  23. /// </summary>
  24. public string SubscriberId
  25. {
  26. get { return subscriberId; }
  27. }
  28. /// <summary>
  29. /// Type of storage that this log writer manages.
  30. /// </summary>
  31. internal LogConfigEventLogStorageType StorageType
  32. {
  33. get { return storageType; }
  34. }
  35. #endregion
  36. #region Methods
  37. /// <summary>
  38. /// Publishes the specified entry to the event publisher. If it is not
  39. /// an event log entry, it is just ignored.
  40. /// </summary>
  41. /// <param name="logEntry"></param>
  42. public override void PerformWrite(LogEntry logEntry)
  43. {
  44. EventLogEntry eventLogEntry = logEntry as EventLogEntry;
  45. if (eventLogEntry != null)
  46. Logger.PublishEventLog(this.subscriberId, eventLogEntry, this.storageType);
  47. }
  48. /// <summary>
  49. /// Disposes the internal resources.
  50. /// </summary>
  51. /// <param name="disposing"></param>
  52. /// <param name="reason"></param>
  53. protected override void Dispose(bool disposing, string reason)
  54. {
  55. }
  56. #endregion
  57. }
  58. }