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)
130 public void Write<T> (string eventName, T data)
134 public void Write<T> (string eventName, EventSourceOptions options, T data)
138 public void Write<T> (string eventName, ref EventSourceOptions options, ref T data)
142 public void Write<T> (string eventName, ref EventSourceOptions options, ref Guid activityId, ref Guid relatedActivityId, ref T data)
147 protected virtual void Dispose (bool disposing)
151 protected virtual void OnEventCommand (EventCommandEventArgs command)
155 protected void WriteEvent (int eventId)
157 WriteEvent (eventId, new object[] { } );
160 protected void WriteEvent (int eventId, byte[] arg1)
162 WriteEvent (eventId, new object[] { arg1 } );
165 protected void WriteEvent (int eventId, int arg1)
167 WriteEvent (eventId, new object[] { arg1 } );
170 protected void WriteEvent (int eventId, string arg1)
172 WriteEvent (eventId, new object[] { arg1 } );
175 protected void WriteEvent (int eventId, int arg1, int arg2)
177 WriteEvent (eventId, new object[] { arg1, arg2 } );
180 protected void WriteEvent (int eventId, int arg1, int arg2, int arg3)
182 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
185 protected void WriteEvent (int eventId, int arg1, string arg2)
187 WriteEvent (eventId, new object[] { arg1, arg2 } );
190 protected void WriteEvent (int eventId, long arg1)
192 WriteEvent (eventId, new object[] { arg1 } );
195 protected void WriteEvent (int eventId, long arg1, byte[] arg2)
197 WriteEvent (eventId, new object[] { arg1, arg2 } );
200 protected void WriteEvent (int eventId, long arg1, long arg2)
202 WriteEvent (eventId, new object[] { arg1, arg2 } );
205 protected void WriteEvent (int eventId, long arg1, long arg2, long arg3)
207 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
210 protected void WriteEvent (int eventId, long arg1, string arg2)
212 WriteEvent (eventId, new object[] { arg1, arg2 } );
215 protected void WriteEvent (int eventId, params object[] args)
219 protected void WriteEvent (int eventId, string arg1, int arg2)
221 WriteEvent (eventId, new object[] { arg1, arg2 } );
224 protected void WriteEvent (int eventId, string arg1, int arg2, int arg3)
226 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
229 protected void WriteEvent (int eventId, string arg1, long arg2)
231 WriteEvent (eventId, new object[] { arg1, arg2 } );
234 protected void WriteEvent (int eventId, string arg1, string arg2)
236 WriteEvent (eventId, new object[] { arg1, arg2 } );
239 protected void WriteEvent (int eventId, string arg1, string arg2, string arg3)
241 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );