d4bdca0b664af2f3bd4065754035f086ffc97e0d
[mono.git] / mcs / class / System / System.Diagnostics / Trace.cs
1 //
2 // System.Diagnostics.Trace.cs
3 //
4 // Authors:
5 //   Jonathan Pryor (jonpryor@vt.edu)
6 //
7 // Comments from John R. Hicks <angryjohn69@nc.rr.com> original implementation 
8 // can be found at: /mcs/docs/apidocs/xml/en/System.Diagnostics
9 //
10 // (C) 2002
11 //
12
13 //
14 // Permission is hereby granted, free of charge, to any person obtaining
15 // a copy of this software and associated documentation files (the
16 // "Software"), to deal in the Software without restriction, including
17 // without limitation the rights to use, copy, modify, merge, publish,
18 // distribute, sublicense, and/or sell copies of the Software, and to
19 // permit persons to whom the Software is furnished to do so, subject to
20 // the following conditions:
21 // 
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
24 // 
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 //
33
34 using System;
35 using System.Diagnostics;
36 using System.Reflection;
37
38 namespace System.Diagnostics {
39
40         public sealed class Trace {
41
42                 private Trace () {}
43
44                 [MonoNotSupported ("")]
45                 public static void Refresh ()
46                 {
47                         throw new NotImplementedException ();
48                 }
49
50                 public static bool AutoFlush {
51                         get {return TraceImpl.AutoFlush;}
52                         set {TraceImpl.AutoFlush = value;}
53                 }
54
55                 public static int IndentLevel {
56                         get {return TraceImpl.IndentLevel;}
57                         set {TraceImpl.IndentLevel = value;}
58                 }
59
60                 public static int IndentSize {
61                         get {return TraceImpl.IndentSize;}
62                         set {TraceImpl.IndentSize = value;}
63                 }
64
65                 public static TraceListenerCollection Listeners {
66                         get {return TraceImpl.Listeners;}
67                 }
68
69                 public static CorrelationManager CorrelationManager {
70                         get { return TraceImpl.CorrelationManager; }
71                 }
72
73                 public static bool UseGlobalLock {
74                         get { return TraceImpl.UseGlobalLock; }
75                         set { TraceImpl.UseGlobalLock = value; }
76                 }
77
78                 [Conditional("TRACE")]
79                 public static void Assert (bool condition)
80                 {
81                         TraceImpl.Assert (condition);
82                 }
83
84                 [Conditional("TRACE")]
85                 public static void Assert (bool condition, string message)
86                 {
87                         TraceImpl.Assert (condition, message);
88                 }
89
90                 [Conditional("TRACE")]
91                 public static void Assert (bool condition, string message, 
92                         string detailMessage)
93                 {
94                         TraceImpl.Assert (condition, message, detailMessage);
95                 }
96
97                 [Conditional("TRACE")]
98                 public static void Close ()
99                 {
100                         TraceImpl.Close ();
101                 }
102
103                 [Conditional("TRACE")]
104                 public static void Fail (string message)
105                 {
106                         TraceImpl.Fail (message);
107                 }
108
109                 [Conditional("TRACE")]
110                 public static void Fail (string message, string detailMessage)
111                 {
112                         TraceImpl.Fail (message, detailMessage);
113                 }
114
115                 [Conditional("TRACE")]
116                 public static void Flush ()
117                 {
118                         TraceImpl.Flush ();
119                 }
120
121                 [Conditional("TRACE")]
122                 public static void Indent ()
123                 {
124                         TraceImpl.Indent ();
125                 }
126
127                 [Conditional("TRACE")]
128                 public static void Unindent ()
129                 {
130                         TraceImpl.Unindent ();
131                 }
132
133                 [Conditional("TRACE")]
134                 public static void Write (object value)
135                 {
136                         TraceImpl.Write (value);
137                 }
138
139                 [Conditional("TRACE")]
140                 public static void Write (string message)
141                 {
142                         TraceImpl.Write (message);
143                 }
144
145                 [Conditional("TRACE")]
146                 public static void Write (object value, string category)
147                 {
148                         TraceImpl.Write (value, category);
149                 }
150
151                 [Conditional("TRACE")]
152                 public static void Write (string message, string category)
153                 {
154                         TraceImpl.Write (message, category);
155                 }
156
157                 [Conditional("TRACE")]
158                 public static void WriteIf (bool condition, object value)
159                 {
160                         TraceImpl.WriteIf (condition, value);
161                 }
162
163                 [Conditional("TRACE")]
164                 public static void WriteIf (bool condition, string message)
165                 {
166                         TraceImpl.WriteIf (condition, message);
167                 }
168
169                 [Conditional("TRACE")]
170                 public static void WriteIf (bool condition, object value, 
171                         string category)
172                 {
173                         TraceImpl.WriteIf (condition, value, category);
174                 }
175
176                 [Conditional("TRACE")]
177                 public static void WriteIf (bool condition, string message, 
178                         string category)
179                 {
180                         TraceImpl.WriteIf (condition, message, category);
181                 }
182
183                 [Conditional("TRACE")]
184                 public static void WriteLine (object value)
185                 {
186                         TraceImpl.WriteLine (value);
187                 }
188
189                 [Conditional("TRACE")]
190                 public static void WriteLine (string message)
191                 {
192                         TraceImpl.WriteLine (message);
193                 }
194
195                 [Conditional("TRACE")]
196                 public static void WriteLine (object value, string category)
197                 {
198                         TraceImpl.WriteLine (value, category);
199                 }
200
201                 [Conditional("TRACE")]
202                 public static void WriteLine (string message, string category)
203                 {
204                         TraceImpl.WriteLine (message, category);
205                 }
206
207                 [Conditional("TRACE")]
208                 public static void WriteLineIf (bool condition, object value)
209                 {
210                         TraceImpl.WriteLineIf (condition, value);
211                 }
212
213                 [Conditional("TRACE")]
214                 public static void WriteLineIf (bool condition, string message)
215                 {
216                         TraceImpl.WriteLineIf (condition, message);
217                 }
218
219                 [Conditional("TRACE")]
220                 public static void WriteLineIf (bool condition, object value, 
221                         string category)
222                 {
223                         TraceImpl.WriteLineIf (condition, value, category);
224                 }
225
226                 [Conditional("TRACE")]
227                 public static void WriteLineIf (bool condition, string message, 
228                         string category)
229                 {
230                         TraceImpl.WriteLineIf (condition, message, category);
231                 }
232
233                 static void DoTrace (string kind, Assembly report, string message)
234                 {
235                         TraceImpl.WriteLine (String.Format ("{0} {1} : 0 : {2}", report.Location, kind, message));
236                 }
237                 
238                 [Conditional("TRACE")]
239                 public static void TraceError (string message)
240                 {
241                         DoTrace ("Error", Assembly.GetCallingAssembly (), message);
242                 }
243
244                 [Conditional("TRACE")]
245                 public static void TraceError (string message, params object [] args)
246                 {
247                         DoTrace ("Error", Assembly.GetCallingAssembly (), String.Format (message, args));
248                 }
249
250                 [Conditional("TRACE")]
251                 public static void TraceInformation (string message)
252                 {
253                         DoTrace ("Information", Assembly.GetCallingAssembly (), message);
254                 }
255
256                 [Conditional("TRACE")]
257                 public static void TraceInformation (string message, params object [] args)
258                 {
259                         DoTrace ("Information", Assembly.GetCallingAssembly (), String.Format (message, args));
260                 }
261
262                 [Conditional("TRACE")]
263                 public static void TraceWarning (string message)
264                 {
265                         DoTrace ("Warning", Assembly.GetCallingAssembly (), message);
266                 }
267
268                 [Conditional("TRACE")]
269                 public static void TraceWarning (string message, params object [] args)
270                 {
271                         DoTrace ("Warning", Assembly.GetCallingAssembly (), String.Format (message, args));
272                 }
273         }
274 }
275
276