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 internal struct EventData
38 public IntPtr DataPointer { get; set; }
39 public int Size { get; set; }
42 protected EventSource ()
44 this.Name = this.GetType().Name;
47 protected EventSource (bool throwOnEventWriteErrors)
52 protected EventSource (EventSourceSettings settings)
55 this.Settings = settings;
58 protected EventSource (EventSourceSettings settings, params string[] traits)
63 public EventSource (string eventSourceName)
65 this.Name = eventSourceName;
68 public EventSource (string eventSourceName, EventSourceSettings config)
69 : this (eventSourceName)
71 this.Settings = config;
74 public EventSource (string eventSourceName, EventSourceSettings config, params string[] traits)
75 : this (eventSourceName, config)
79 public Exception ConstructionException
84 public static Guid CurrentThreadActivityId
86 get { return Guid.Empty; }
91 get { return Guid.Empty; }
100 public EventSourceSettings Settings
106 public bool IsEnabled ()
111 public bool IsEnabled (EventLevel level, EventKeywords keywords)
116 public bool IsEnabled (EventLevel level, EventKeywords keywords, EventChannel channel)
121 public void Dispose ()
126 public string GetTrait (string key)
131 public void Write (string eventName)
135 public void Write<T> (string eventName, T data)
139 public void Write<T> (string eventName, EventSourceOptions options, T data)
143 public void Write<T> (string eventName, ref EventSourceOptions options, ref T data)
147 public void Write<T> (string eventName, ref EventSourceOptions options, ref Guid activityId, ref Guid relatedActivityId, ref T data)
151 protected virtual void Dispose (bool disposing)
155 protected virtual void OnEventCommand (EventCommandEventArgs command)
159 protected void WriteEvent (int eventId)
161 WriteEvent (eventId, new object[] { } );
164 protected void WriteEvent (int eventId, byte[] arg1)
166 WriteEvent (eventId, new object[] { arg1 } );
169 protected void WriteEvent (int eventId, int arg1)
171 WriteEvent (eventId, new object[] { arg1 } );
174 protected void WriteEvent (int eventId, string arg1)
176 WriteEvent (eventId, new object[] { arg1 } );
179 protected void WriteEvent (int eventId, int arg1, int arg2)
181 WriteEvent (eventId, new object[] { arg1, arg2 } );
184 protected void WriteEvent (int eventId, int arg1, int arg2, int arg3)
186 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
189 protected void WriteEvent (int eventId, int arg1, string arg2)
191 WriteEvent (eventId, new object[] { arg1, arg2 } );
194 protected void WriteEvent (int eventId, long arg1)
196 WriteEvent (eventId, new object[] { arg1 } );
199 protected void WriteEvent (int eventId, long arg1, byte[] arg2)
201 WriteEvent (eventId, new object[] { arg1, arg2 } );
204 protected void WriteEvent (int eventId, long arg1, long arg2)
206 WriteEvent (eventId, new object[] { arg1, arg2 } );
209 protected void WriteEvent (int eventId, long arg1, long arg2, long arg3)
211 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
214 protected void WriteEvent (int eventId, long arg1, string arg2)
216 WriteEvent (eventId, new object[] { arg1, arg2 } );
219 protected void WriteEvent (int eventId, params object[] args)
223 protected void WriteEvent (int eventId, string arg1, int arg2)
225 WriteEvent (eventId, new object[] { arg1, arg2 } );
228 protected void WriteEvent (int eventId, string arg1, int arg2, int arg3)
230 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
233 protected void WriteEvent (int eventId, string arg1, long arg2)
235 WriteEvent (eventId, new object[] { arg1, arg2 } );
238 protected void WriteEvent (int eventId, string arg1, string arg2)
240 WriteEvent (eventId, new object[] { arg1, arg2 } );
243 protected void WriteEvent (int eventId, string arg1, string arg2, string arg3)
245 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );