2using System.Collections.Generic;
4using System.Threading.Tasks;
21 private bool disposed =
false;
40 return Task.CompletedTask;
48 return Task.CompletedTask;
71 await this.semaphore.BeginWrite();
77 if (!(this.output is
null))
79 this.output.WriteStartElement(
Event.
Type.ToString());
80 this.output.WriteAttributeString(
"timestamp", Encode(
Event.
Timestamp));
81 this.output.WriteAttributeString(
"level",
Event.
Level.ToString());
88 this.output.WriteAttributeString(
"object",
Event.
Object);
91 this.output.WriteAttributeString(
"actor",
Event.
Actor);
94 this.output.WriteAttributeString(
"module",
Event.
Module);
99 this.output.WriteStartElement(
"Message");
102 this.output.WriteElementString(
"Row", Row);
104 this.output.WriteEndElement();
108 foreach (KeyValuePair<string, object> Tag
in Event.
Tags)
110 this.output.WriteStartElement(
"Tag");
111 this.output.WriteAttributeString(
"key", Tag.Key);
113 if (!(Tag.Value is
null))
114 this.output.WriteAttributeString(
"value", Tag.Value.ToString());
116 this.output.WriteEndElement();
122 this.output.WriteStartElement(
"StackTrace");
125 this.output.WriteElementString(
"Row", Row);
127 this.output.WriteEndElement();
130 this.output.WriteEndElement();
152 await this.semaphore.EndWrite();
156 internal static string Encode(DateTime DT)
158 StringBuilder sb =
new StringBuilder();
160 sb.Append(DT.Year.ToString(
"D4"));
162 sb.Append(DT.Month.ToString(
"D2"));
164 sb.Append(DT.Day.ToString(
"D2"));
166 sb.Append(DT.Hour.ToString(
"D2"));
168 sb.Append(DT.Minute.ToString(
"D2"));
170 sb.Append(DT.Second.ToString(
"D2"));
172 sb.Append(DT.Millisecond.ToString(
"D3"));
174 if (DT.Kind == DateTimeKind.Utc)
177 return sb.ToString();
185 this.output?.Flush();
186 this.output?.Dispose();
Class representing an event.
string Message
Free-text event message.
EventType Type
Type of event.
string Object
Object related to the event.
EventLevel Level
Event Level.
string Actor
Actor responsible for the action causing the event.
string Module
Module where the event is reported.
DateTime Timestamp
Timestamp of event.
KeyValuePair< string, object >[] Tags
Variable set of tags providing event-specific information.
string EventId
Computer-readable Event ID identifying type of even.
string Facility
Facility can be either a facility in the network sense or in the system sense.
string StackTrace
Stack Trace of event.
Base class for event sinks.
Outputs sniffed data to an XML writer.
virtual void DisposeOutput()
Disposes of the current output.
XmlWriter output
XML writer object.
override void Dispose()
IDisposable.Dispose
override async Task Queue(Event Event)
Queues an event to be output.
virtual Task AfterWrite()
Method is called after writing something to the text file.
virtual Task BeforeWrite()
Method is called before writing something to the text file.
XmlWriterEventSink(string ObjectID, XmlWriter Output)
Outputs sniffed data to an XML writer.
virtual string ObjectID
Object ID, used when logging events.
Represents an object that allows single concurrent writers but multiple concurrent readers....