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