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.
31 using System.Collections.Generic;
33 namespace System.Diagnostics.Tracing
35 public class EventSource : IDisposable
37 protected internal struct EventData
39 public IntPtr DataPointer { get; set; }
40 public int Size { get; set; }
43 protected EventSource ()
45 this.Name = this.GetType().Name;
48 protected EventSource (bool throwOnEventWriteErrors)
53 protected EventSource (EventSourceSettings settings)
56 this.Settings = settings;
59 protected EventSource (EventSourceSettings settings, params string[] traits)
64 public EventSource (string eventSourceName)
66 this.Name = eventSourceName;
69 public EventSource (string eventSourceName, EventSourceSettings config)
70 : this (eventSourceName)
72 this.Settings = config;
75 public EventSource (string eventSourceName, EventSourceSettings config, params string[] traits)
76 : this (eventSourceName, config)
85 public Exception ConstructionException
90 public static Guid CurrentThreadActivityId
92 get { return Guid.Empty; }
97 get { return Guid.Empty; }
106 public EventSourceSettings Settings
112 public bool IsEnabled ()
117 public bool IsEnabled (EventLevel level, EventKeywords keywords)
122 public bool IsEnabled (EventLevel level, EventKeywords keywords, EventChannel channel)
127 public void Dispose ()
130 GC.SuppressFinalize (this);
133 public string GetTrait (string key)
138 public void Write (string eventName)
142 public void Write (string eventName, EventSourceOptions options)
146 public void Write<T> (string eventName, T data)
150 public void Write<T> (string eventName, EventSourceOptions options, T data)
154 [CLSCompliant (false)]
155 public void Write<T> (string eventName, ref EventSourceOptions options, ref T data)
159 public void Write<T> (string eventName, ref EventSourceOptions options, ref Guid activityId, ref Guid relatedActivityId, ref T data)
163 protected virtual void Dispose (bool disposing)
167 protected virtual void OnEventCommand (EventCommandEventArgs command)
171 protected void WriteEvent (int eventId)
173 WriteEvent (eventId, new object[] { } );
176 protected void WriteEvent (int eventId, byte[] arg1)
178 WriteEvent (eventId, new object[] { arg1 } );
181 protected void WriteEvent (int eventId, int arg1)
183 WriteEvent (eventId, new object[] { arg1 } );
186 protected void WriteEvent (int eventId, string arg1)
188 WriteEvent (eventId, new object[] { arg1 } );
191 protected void WriteEvent (int eventId, int arg1, int arg2)
193 WriteEvent (eventId, new object[] { arg1, arg2 } );
196 protected void WriteEvent (int eventId, int arg1, int arg2, int arg3)
198 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
201 protected void WriteEvent (int eventId, int arg1, string arg2)
203 WriteEvent (eventId, new object[] { arg1, arg2 } );
206 protected void WriteEvent (int eventId, long arg1)
208 WriteEvent (eventId, new object[] { arg1 } );
211 protected void WriteEvent (int eventId, long arg1, byte[] arg2)
213 WriteEvent (eventId, new object[] { arg1, arg2 } );
216 protected void WriteEvent (int eventId, long arg1, long arg2)
218 WriteEvent (eventId, new object[] { arg1, arg2 } );
221 protected void WriteEvent (int eventId, long arg1, long arg2, long arg3)
223 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
226 protected void WriteEvent (int eventId, long arg1, string arg2)
228 WriteEvent (eventId, new object[] { arg1, arg2 } );
231 protected void WriteEvent (int eventId, params object[] args)
235 protected void WriteEvent (int eventId, string arg1, int arg2)
237 WriteEvent (eventId, new object[] { arg1, arg2 } );
240 protected void WriteEvent (int eventId, string arg1, int arg2, int arg3)
242 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
245 protected void WriteEvent (int eventId, string arg1, long arg2)
247 WriteEvent (eventId, new object[] { arg1, arg2 } );
250 protected void WriteEvent (int eventId, string arg1, string arg2)
252 WriteEvent (eventId, new object[] { arg1, arg2 } );
255 protected void WriteEvent (int eventId, string arg1, string arg2, string arg3)
257 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
260 [CLSCompliant (false)]
261 protected unsafe void WriteEventCore (int eventId, int eventDataCount, EventData* data)
265 protected unsafe void WriteEventWithRelatedActivityId (int eventId, Guid relatedActivityId, params object[] args)
269 [CLSCompliant (false)]
270 protected unsafe void WriteEventWithRelatedActivityIdCore (int eventId, Guid* relatedActivityId, int eventDataCount, EventSource.EventData* data)
275 public event EventHandler<EventCommandEventArgs> EventCommandExecuted
277 add { throw new NotImplementedException (); }
278 remove { throw new NotImplementedException (); }
282 public static string GenerateManifest (Type eventSourceType, string assemblyPathToIncludeInManifest)
284 throw new NotImplementedException ();
288 public static string GenerateManifest (Type eventSourceType, string assemblyPathToIncludeInManifest, EventManifestOptions flags)
290 throw new NotImplementedException ();
294 public static Guid GetGuid (Type eventSourceType)
296 throw new NotImplementedException ();
300 public static string GetName (Type eventSourceType)
302 throw new NotImplementedException ();
306 public static IEnumerable<EventSource> GetSources ()
308 throw new NotImplementedException ();
312 public static void SendCommand (EventSource eventSource, EventCommand command, IDictionary<string, string> commandArguments)
314 throw new NotImplementedException ();
318 public static void SetCurrentThreadActivityId (Guid activityId)
320 throw new NotImplementedException ();
324 public static void SetCurrentThreadActivityId (Guid activityId, out Guid oldActivityThatWillContinue)
326 throw new NotImplementedException ();