2 // System.Diagnostics.Trace.cs
5 // Jonathan Pryor (jonpryor@vt.edu)
7 // Comments from John R. Hicks <angryjohn69@nc.rr.com> original implementation
8 // can be found at: /mcs/docs/apidocs/xml/en/System.Diagnostics
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:
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
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.
35 using System.Diagnostics;
36 using System.Reflection;
38 namespace System.Diagnostics {
40 public sealed class Trace {
44 [MonoNotSupported ("")]
45 public static void Refresh ()
47 throw new NotImplementedException ();
50 public static bool AutoFlush {
51 get {return TraceImpl.AutoFlush;}
52 set {TraceImpl.AutoFlush = value;}
55 public static int IndentLevel {
56 get {return TraceImpl.IndentLevel;}
57 set {TraceImpl.IndentLevel = value;}
60 public static int IndentSize {
61 get {return TraceImpl.IndentSize;}
62 set {TraceImpl.IndentSize = value;}
65 public static TraceListenerCollection Listeners {
66 get {return TraceImpl.Listeners;}
69 public static CorrelationManager CorrelationManager {
70 get { return TraceImpl.CorrelationManager; }
73 public static bool UseGlobalLock {
74 get { return TraceImpl.UseGlobalLock; }
75 set { TraceImpl.UseGlobalLock = value; }
78 [Conditional("TRACE")]
79 public static void Assert (bool condition)
81 TraceImpl.Assert (condition);
84 [Conditional("TRACE")]
85 public static void Assert (bool condition, string message)
87 TraceImpl.Assert (condition, message);
90 [Conditional("TRACE")]
91 public static void Assert (bool condition, string message,
94 TraceImpl.Assert (condition, message, detailMessage);
97 [Conditional("TRACE")]
98 public static void Close ()
103 [Conditional("TRACE")]
104 public static void Fail (string message)
106 TraceImpl.Fail (message);
109 [Conditional("TRACE")]
110 public static void Fail (string message, string detailMessage)
112 TraceImpl.Fail (message, detailMessage);
115 [Conditional("TRACE")]
116 public static void Flush ()
121 [Conditional("TRACE")]
122 public static void Indent ()
127 [Conditional("TRACE")]
128 public static void Unindent ()
130 TraceImpl.Unindent ();
133 [Conditional("TRACE")]
134 public static void Write (object value)
136 TraceImpl.Write (value);
139 [Conditional("TRACE")]
140 public static void Write (string message)
142 TraceImpl.Write (message);
145 [Conditional("TRACE")]
146 public static void Write (object value, string category)
148 TraceImpl.Write (value, category);
151 [Conditional("TRACE")]
152 public static void Write (string message, string category)
154 TraceImpl.Write (message, category);
157 [Conditional("TRACE")]
158 public static void WriteIf (bool condition, object value)
160 TraceImpl.WriteIf (condition, value);
163 [Conditional("TRACE")]
164 public static void WriteIf (bool condition, string message)
166 TraceImpl.WriteIf (condition, message);
169 [Conditional("TRACE")]
170 public static void WriteIf (bool condition, object value,
173 TraceImpl.WriteIf (condition, value, category);
176 [Conditional("TRACE")]
177 public static void WriteIf (bool condition, string message,
180 TraceImpl.WriteIf (condition, message, category);
183 [Conditional("TRACE")]
184 public static void WriteLine (object value)
186 TraceImpl.WriteLine (value);
189 [Conditional("TRACE")]
190 public static void WriteLine (string message)
192 TraceImpl.WriteLine (message);
195 [Conditional("TRACE")]
196 public static void WriteLine (object value, string category)
198 TraceImpl.WriteLine (value, category);
201 [Conditional("TRACE")]
202 public static void WriteLine (string message, string category)
204 TraceImpl.WriteLine (message, category);
207 [Conditional("TRACE")]
208 public static void WriteLineIf (bool condition, object value)
210 TraceImpl.WriteLineIf (condition, value);
213 [Conditional("TRACE")]
214 public static void WriteLineIf (bool condition, string message)
216 TraceImpl.WriteLineIf (condition, message);
219 [Conditional("TRACE")]
220 public static void WriteLineIf (bool condition, object value,
223 TraceImpl.WriteLineIf (condition, value, category);
226 [Conditional("TRACE")]
227 public static void WriteLineIf (bool condition, string message,
230 TraceImpl.WriteLineIf (condition, message, category);
233 static void DoTrace (string kind, Assembly report, string message)
235 TraceImpl.WriteLine (String.Format ("{0} {1} : 0 : {2}", report.Location, kind, message));
238 [Conditional("TRACE")]
239 public static void TraceError (string message)
241 DoTrace ("Error", Assembly.GetCallingAssembly (), message);
244 [Conditional("TRACE")]
245 public static void TraceError (string message, params object [] args)
247 DoTrace ("Error", Assembly.GetCallingAssembly (), String.Format (message, args));
250 [Conditional("TRACE")]
251 public static void TraceInformation (string message)
253 DoTrace ("Information", Assembly.GetCallingAssembly (), message);
256 [Conditional("TRACE")]
257 public static void TraceInformation (string message, params object [] args)
259 DoTrace ("Information", Assembly.GetCallingAssembly (), String.Format (message, args));
262 [Conditional("TRACE")]
263 public static void TraceWarning (string message)
265 DoTrace ("Warning", Assembly.GetCallingAssembly (), message);
268 [Conditional("TRACE")]
269 public static void TraceWarning (string message, params object [] args)
271 DoTrace ("Warning", Assembly.GetCallingAssembly (), String.Format (message, args));