[bcl] netstandart 1.6 support
[mono.git] / mcs / class / corlib / System.Diagnostics.Tracing / EventSource.cs
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)
10 //
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:
18 //
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 //
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.
29 //
30
31
32 namespace System.Diagnostics.Tracing
33 {
34         public class EventSource : IDisposable
35         {
36                 protected internal struct EventData
37                 {
38                         public IntPtr DataPointer { get; set; }
39                         public int Size { get; set; }
40                 }
41
42                 protected EventSource ()
43                 {
44                         this.Name = this.GetType().Name;
45                 }
46
47                 protected EventSource (bool throwOnEventWriteErrors)
48                         : this ()
49                 {
50                 }
51
52                 protected EventSource (EventSourceSettings settings)
53                         : this ()
54                 {
55                         this.Settings = settings;
56                 }
57
58                 protected EventSource (EventSourceSettings settings, params string[] traits)
59                         : this (settings)
60                 {
61                 }
62
63                 public EventSource (string eventSourceName)
64                 {
65                         this.Name = eventSourceName;
66                 }
67
68                 public EventSource (string eventSourceName, EventSourceSettings config)
69                         : this (eventSourceName)
70                 {
71                         this.Settings = config;
72                 }
73
74                 public EventSource (string eventSourceName, EventSourceSettings config, params string[] traits)
75                         : this (eventSourceName, config)
76                 {
77                 }
78
79                 public Exception ConstructionException
80                 {
81                         get { return null; }
82                 }
83
84                 public static Guid CurrentThreadActivityId
85                 {
86                         get { return Guid.Empty; }
87                 }
88
89                 public Guid Guid
90                 {
91                         get { return Guid.Empty; }
92                 }
93
94                 public string Name
95                 {
96                         get;
97                         private set;
98                 }
99
100                 public EventSourceSettings Settings
101                 {
102                         get;
103                         private set;
104                 }
105
106                 public bool IsEnabled ()
107                 {
108                         return false;
109                 }
110
111                 public bool IsEnabled (EventLevel level, EventKeywords keywords)
112                 {
113                         return false;
114                 }
115
116                 public bool IsEnabled (EventLevel level, EventKeywords keywords, EventChannel channel)
117                 {
118                         return false;
119                 }
120
121                 public void Dispose ()
122                 {
123                         Dispose (true);
124                 }
125
126                 public string GetTrait (string key)
127                 {
128                         return null;
129                 }
130
131                 public void Write (string eventName)
132                 {
133                 }
134
135                 public void Write<T> (string eventName, T data)
136                 {
137                 }
138
139                 public void Write<T> (string eventName, EventSourceOptions options, T data)
140                 {
141                 }
142
143                 public void Write<T> (string eventName, ref EventSourceOptions options, ref T data)
144                 {
145                 }
146
147                 public void Write<T> (string eventName, ref EventSourceOptions options, ref Guid activityId, ref Guid relatedActivityId, ref T data)
148                 {
149                 }
150
151                 protected virtual void Dispose (bool disposing)
152                 {
153                 }
154
155                 protected virtual void OnEventCommand (EventCommandEventArgs command)
156                 {
157                 }
158
159                 protected void WriteEvent (int eventId)
160                 {
161                         WriteEvent (eventId, new object[] { } );
162                 }
163
164                 protected void WriteEvent (int eventId, byte[] arg1)
165                 {
166                         WriteEvent (eventId, new object[] { arg1 } );
167                 }
168
169                 protected void WriteEvent (int eventId, int arg1)
170                 {
171                         WriteEvent (eventId, new object[] { arg1 } );
172                 }
173
174                 protected void WriteEvent (int eventId, string arg1)
175                 {
176                         WriteEvent (eventId, new object[] { arg1 } );
177                 }
178
179                 protected void WriteEvent (int eventId, int arg1, int arg2)
180                 {
181                         WriteEvent (eventId, new object[] { arg1, arg2 } );
182                 }
183
184                 protected void WriteEvent (int eventId, int arg1, int arg2, int arg3)
185                 {
186                         WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
187                 }
188
189                 protected void WriteEvent (int eventId, int arg1, string arg2)
190                 {
191                         WriteEvent (eventId, new object[] { arg1, arg2 } );
192                 }
193
194                 protected void WriteEvent (int eventId, long arg1)
195                 {
196                         WriteEvent (eventId, new object[] { arg1 } );
197                 }
198
199                 protected void WriteEvent (int eventId, long arg1, byte[] arg2)
200                 {
201                         WriteEvent (eventId, new object[] { arg1, arg2 } );
202                 }
203
204                 protected void WriteEvent (int eventId, long arg1, long arg2)
205                 {
206                         WriteEvent (eventId, new object[] { arg1, arg2 } );
207                 }
208
209                 protected void WriteEvent (int eventId, long arg1, long arg2, long arg3)
210                 {
211                         WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
212                 }
213
214                 protected void WriteEvent (int eventId, long arg1, string arg2)
215                 {
216                         WriteEvent (eventId, new object[] { arg1, arg2 } );
217                 }
218
219                 protected void WriteEvent (int eventId, params object[] args)
220                 {
221                 }
222
223                 protected void WriteEvent (int eventId, string arg1, int arg2)
224                 {
225                         WriteEvent (eventId, new object[] { arg1, arg2 } );
226                 }
227
228                 protected void WriteEvent (int eventId, string arg1, int arg2, int arg3)
229                 {
230                         WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
231                 }
232
233                 protected void WriteEvent (int eventId, string arg1, long arg2)
234                 {
235                         WriteEvent (eventId, new object[] { arg1, arg2 } );
236                 }
237
238                 protected void WriteEvent (int eventId, string arg1, string arg2)
239                 {
240                         WriteEvent (eventId, new object[] { arg1, arg2 } );
241                 }
242
243                 protected void WriteEvent (int eventId, string arg1, string arg2, string arg3)
244                 {
245                         WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
246                 }
247         }
248 }
249