5 // Marek Safar <marek.safar@gmail.com>
6 // Frederik Carlier <frederik.carlier@quamotion.mobi>
8 // Copyright (C) 2014 Xamarin Inc (http://www.xamarin.com)
9 // Copyrithg (C) 2015 Quamotion (http://quamotion.mobi)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 namespace System.Diagnostics.Tracing
34 public class EventSource : IDisposable
36 protected EventSource ()
38 this.Name = this.GetType().Name;
41 protected EventSource (bool throwOnEventWriteErrors)
46 protected EventSource (EventSourceSettings settings)
49 this.Settings = settings;
52 protected EventSource (EventSourceSettings settings, params string[] traits)
57 public EventSource (string eventSourceName)
59 this.Name = eventSourceName;
62 public EventSource (string eventSourceName, EventSourceSettings config)
63 : this (eventSourceName)
65 this.Settings = config;
68 public EventSource (string eventSourceName, EventSourceSettings config, params string[] traits)
69 : this (eventSourceName, config)
73 public Exception ConstructionException
78 public static Guid CurrentThreadActivityId
80 get { return Guid.Empty; }
85 get { return Guid.Empty; }
94 public EventSourceSettings Settings
100 public bool IsEnabled ()
105 public bool IsEnabled (EventLevel level, EventKeywords keywords)
110 public bool IsEnabled (EventLevel level, EventKeywords keywords, EventChannel channel)
115 public void Dispose ()
120 public string GetTrait (string key)
125 public void Write (string eventName)
129 public void Write<T> (string eventName, T data)
133 public void Write<T> (string eventName, EventSourceOptions options, T data)
137 public void Write<T> (string eventName, ref EventSourceOptions options, ref T data)
141 public void Write<T> (string eventName, ref EventSourceOptions options, ref Guid activityId, ref Guid relatedActivityId, ref T data)
145 protected virtual void Dispose (bool disposing)
149 protected virtual void OnEventCommand (EventCommandEventArgs command)
153 protected void WriteEvent (int eventId)
155 WriteEvent (eventId, new object[] { } );
158 protected void WriteEvent (int eventId, byte[] arg1)
160 WriteEvent (eventId, new object[] { arg1 } );
163 protected void WriteEvent (int eventId, int arg1)
165 WriteEvent (eventId, new object[] { arg1 } );
168 protected void WriteEvent (int eventId, string arg1)
170 WriteEvent (eventId, new object[] { arg1 } );
173 protected void WriteEvent (int eventId, int arg1, int arg2)
175 WriteEvent (eventId, new object[] { arg1, arg2 } );
178 protected void WriteEvent (int eventId, int arg1, int arg2, int arg3)
180 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
183 protected void WriteEvent (int eventId, int arg1, string arg2)
185 WriteEvent (eventId, new object[] { arg1, arg2 } );
188 protected void WriteEvent (int eventId, long arg1)
190 WriteEvent (eventId, new object[] { arg1 } );
193 protected void WriteEvent (int eventId, long arg1, byte[] arg2)
195 WriteEvent (eventId, new object[] { arg1, arg2 } );
198 protected void WriteEvent (int eventId, long arg1, long arg2)
200 WriteEvent (eventId, new object[] { arg1, arg2 } );
203 protected void WriteEvent (int eventId, long arg1, long arg2, long arg3)
205 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
208 protected void WriteEvent (int eventId, long arg1, string arg2)
210 WriteEvent (eventId, new object[] { arg1, arg2 } );
213 protected void WriteEvent (int eventId, params object[] args)
217 protected void WriteEvent (int eventId, string arg1, int arg2)
219 WriteEvent (eventId, new object[] { arg1, arg2 } );
222 protected void WriteEvent (int eventId, string arg1, int arg2, int arg3)
224 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
227 protected void WriteEvent (int eventId, string arg1, long arg2)
229 WriteEvent (eventId, new object[] { arg1, arg2 } );
232 protected void WriteEvent (int eventId, string arg1, string arg2)
234 WriteEvent (eventId, new object[] { arg1, arg2 } );
237 protected void WriteEvent (int eventId, string arg1, string arg2, string arg3)
239 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );