[bcl] Sync recent NS2.1 changes (#15696)
[mono-project.git] / mcs / class / corlib / System.Diagnostics.Tracing / EventSource.cs
blob66de7367cd56d274e110d5928f3a3a5e9f652b32
1 //
2 // EventSource.cs
3 //
4 // Authors:
5 // Marek Safar <marek.safar@gmail.com>
6 // Frederik Carlier <frederik.carlier@quamotion.mobi>
7 //
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; }
41 internal int Reserved { get; set; }
44 protected EventSource ()
46 this.Name = this.GetType().Name;
49 protected EventSource (bool throwOnEventWriteErrors)
50 : this ()
54 protected EventSource (EventSourceSettings settings)
55 : this ()
57 this.Settings = settings;
60 protected EventSource (EventSourceSettings settings, params string[] traits)
61 : this (settings)
65 public EventSource (string eventSourceName)
67 this.Name = eventSourceName;
70 public EventSource (string eventSourceName, EventSourceSettings config)
71 : this (eventSourceName)
73 this.Settings = config;
76 public EventSource (string eventSourceName, EventSourceSettings config, params string[] traits)
77 : this (eventSourceName, config)
81 internal EventSource (Guid eventSourceGuid, string eventSourceName)
82 : this (eventSourceName)
86 ~EventSource ()
88 Dispose (false);
91 public Exception ConstructionException
93 get { return null; }
96 public static Guid CurrentThreadActivityId
98 get { return Guid.Empty; }
101 public Guid Guid
103 get { return Guid.Empty; }
106 public string Name
108 get;
109 private set;
112 public EventSourceSettings Settings
114 get;
115 private set;
118 public bool IsEnabled ()
120 return false;
123 public bool IsEnabled (EventLevel level, EventKeywords keywords)
125 return false;
128 public bool IsEnabled (EventLevel level, EventKeywords keywords, EventChannel channel)
130 return false;
133 public void Dispose ()
135 Dispose (true);
136 GC.SuppressFinalize (this);
139 public string GetTrait (string key)
141 return null;
144 public void Write (string eventName)
148 public void Write (string eventName, EventSourceOptions options)
152 public void Write<T> (string eventName, T data)
156 public void Write<T> (string eventName, EventSourceOptions options, T data)
160 [CLSCompliant (false)]
161 public void Write<T> (string eventName, ref EventSourceOptions options, ref T data)
165 public void Write<T> (string eventName, ref EventSourceOptions options, ref Guid activityId, ref Guid relatedActivityId, ref T data)
169 protected virtual void Dispose (bool disposing)
173 protected virtual void OnEventCommand (EventCommandEventArgs command)
177 internal void ReportOutOfBandMessage (string msg, bool flush)
181 protected void WriteEvent (int eventId)
183 WriteEvent (eventId, new object[] { } );
186 protected void WriteEvent (int eventId, byte[] arg1)
188 WriteEvent (eventId, new object[] { arg1 } );
191 protected void WriteEvent (int eventId, int arg1)
193 WriteEvent (eventId, new object[] { arg1 } );
196 protected void WriteEvent (int eventId, string arg1)
198 WriteEvent (eventId, new object[] { arg1 } );
201 protected void WriteEvent (int eventId, int arg1, int arg2)
203 WriteEvent (eventId, new object[] { arg1, arg2 } );
206 protected void WriteEvent (int eventId, int arg1, int arg2, int arg3)
208 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
211 protected void WriteEvent (int eventId, int arg1, string arg2)
213 WriteEvent (eventId, new object[] { arg1, arg2 } );
216 protected void WriteEvent (int eventId, long arg1)
218 WriteEvent (eventId, new object[] { arg1 } );
221 protected void WriteEvent (int eventId, long arg1, byte[] arg2)
223 WriteEvent (eventId, new object[] { arg1, arg2 } );
226 protected void WriteEvent (int eventId, long arg1, long arg2)
228 WriteEvent (eventId, new object[] { arg1, arg2 } );
231 protected void WriteEvent (int eventId, long arg1, long arg2, long arg3)
233 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
236 protected void WriteEvent (int eventId, long arg1, string arg2)
238 WriteEvent (eventId, new object[] { arg1, arg2 } );
241 protected void WriteEvent (int eventId, params object[] args)
245 protected void WriteEvent (int eventId, string arg1, int arg2)
247 WriteEvent (eventId, new object[] { arg1, arg2 } );
250 protected void WriteEvent (int eventId, string arg1, int arg2, int arg3)
252 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
255 protected void WriteEvent (int eventId, string arg1, long arg2)
257 WriteEvent (eventId, new object[] { arg1, arg2 } );
260 protected void WriteEvent (int eventId, string arg1, string arg2)
262 WriteEvent (eventId, new object[] { arg1, arg2 } );
265 protected void WriteEvent (int eventId, string arg1, string arg2, string arg3)
267 WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
270 [CLSCompliant (false)]
271 protected unsafe void WriteEventCore (int eventId, int eventDataCount, EventData* data)
275 protected unsafe void WriteEventWithRelatedActivityId (int eventId, Guid relatedActivityId, params object[] args)
279 [CLSCompliant (false)]
280 protected unsafe void WriteEventWithRelatedActivityIdCore (int eventId, Guid* relatedActivityId, int eventDataCount, EventSource.EventData* data)
284 // [MonoTODO]
285 public event EventHandler<EventCommandEventArgs> EventCommandExecuted
287 add { throw new NotImplementedException (); }
288 remove { throw new NotImplementedException (); }
291 // [MonoTODO]
292 public static string GenerateManifest (Type eventSourceType, string assemblyPathToIncludeInManifest)
294 throw new NotImplementedException ();
297 // [MonoTODO]
298 public static string GenerateManifest (Type eventSourceType, string assemblyPathToIncludeInManifest, EventManifestOptions flags)
300 throw new NotImplementedException ();
303 // [MonoTODO]
304 public static Guid GetGuid (Type eventSourceType)
306 throw new NotImplementedException ();
309 // [MonoTODO]
310 public static string GetName (Type eventSourceType)
312 throw new NotImplementedException ();
315 // [MonoTODO]
316 public static IEnumerable<EventSource> GetSources ()
318 throw new NotImplementedException ();
321 // [MonoTODO]
322 public static void SendCommand (EventSource eventSource, EventCommand command, IDictionary<string, string> commandArguments)
324 throw new NotImplementedException ();
327 // [MonoTODO]
328 public static void SetCurrentThreadActivityId (Guid activityId)
330 throw new NotImplementedException ();
333 // [MonoTODO]
334 public static void SetCurrentThreadActivityId (Guid activityId, out Guid oldActivityThatWillContinue)
336 throw new NotImplementedException ();