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 public void Write<T> (string eventName, ref EventSourceOptions options, ref T data)
158 public void Write<T> (string eventName, ref EventSourceOptions options, ref Guid activityId, ref Guid relatedActivityId, ref T data)
162 protected virtual void Dispose (bool disposing)
166 protected virtual void OnEventCommand (EventCommandEventArgs command)
170 protected void WriteEvent (int eventId)
172 WriteEvent (eventId, new object[] { } );
175 protected void WriteEvent (int eventId, byte[] arg1)
177 WriteEvent (eventId, new object[] { arg1 } );
180 protected void WriteEvent (int eventId, int arg1)
182 WriteEvent (eventId, new object[] { arg1 } );
185 protected void WriteEvent (int eventId, string arg1)
187 WriteEvent (eventId, new object[] { arg1 } );
190 protected void WriteEvent (int eventId, int arg1, int arg2)
192 WriteEvent (eventId, new object[] { arg1, arg2 } );
195 protected void WriteEvent (int eventId, int arg1, int arg2, int arg3)
197 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
200 protected void WriteEvent (int eventId, int arg1, string arg2)
202 WriteEvent (eventId, new object[] { arg1, arg2 } );
205 protected void WriteEvent (int eventId, long arg1)
207 WriteEvent (eventId, new object[] { arg1 } );
210 protected void WriteEvent (int eventId, long arg1, byte[] arg2)
212 WriteEvent (eventId, new object[] { arg1, arg2 } );
215 protected void WriteEvent (int eventId, long arg1, long arg2)
217 WriteEvent (eventId, new object[] { arg1, arg2 } );
220 protected void WriteEvent (int eventId, long arg1, long arg2, long arg3)
222 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
225 protected void WriteEvent (int eventId, long arg1, string arg2)
227 WriteEvent (eventId, new object[] { arg1, arg2 } );
230 protected void WriteEvent (int eventId, params object[] args)
234 protected void WriteEvent (int eventId, string arg1, int arg2)
236 WriteEvent (eventId, new object[] { arg1, arg2 } );
239 protected void WriteEvent (int eventId, string arg1, int arg2, int arg3)
241 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
244 protected void WriteEvent (int eventId, string arg1, long arg2)
246 WriteEvent (eventId, new object[] { arg1, arg2 } );
249 protected void WriteEvent (int eventId, string arg1, string arg2)
251 WriteEvent (eventId, new object[] { arg1, arg2 } );
254 protected void WriteEvent (int eventId, string arg1, string arg2, string arg3)
256 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
259 [CLSCompliant (false)]
260 protected unsafe void WriteEventCore (int eventId, int eventDataCount, EventData* data)
264 protected unsafe void WriteEventWithRelatedActivityId (int eventId, Guid relatedActivityId, params object[] args)
268 [CLSCompliant (false)]
269 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 (); }
283 public static string GenerateManifest (Type eventSourceType, string assemblyPathToIncludeInManifest)
285 throw new NotImplementedException ();
289 public static string GenerateManifest (Type eventSourceType, string assemblyPathToIncludeInManifest, EventManifestOptions flags)
291 throw new NotImplementedException ();
295 public static Guid GetGuid (Type eventSourceType)
297 throw new NotImplementedException ();
301 public static string GetName (Type eventSourceType)
303 throw new NotImplementedException ();
307 public static IEnumerable<EventSource> GetSources ()
309 throw new NotImplementedException ();
313 public static void SendCommand (EventSource eventSource, EventCommand command, IDictionary<string, string> commandArguments)
315 throw new NotImplementedException ();
319 public static void SetCurrentThreadActivityId (Guid activityId)
321 throw new NotImplementedException ();
325 public static void SetCurrentThreadActivityId (Guid activityId, out Guid oldActivityThatWillContinue)
327 throw new NotImplementedException ();