2 // System.Diagnostics.Debug.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;
37 namespace System.Diagnostics {
39 public static class Debug {
41 public static bool AutoFlush {
42 get {return TraceImpl.AutoFlush;}
43 set {TraceImpl.AutoFlush = value;}
46 public static int IndentLevel {
47 get {return TraceImpl.IndentLevel;}
48 set {TraceImpl.IndentLevel = value;}
51 public static int IndentSize {
52 get {return TraceImpl.IndentSize;}
53 set {TraceImpl.IndentSize = value;}
56 public static TraceListenerCollection Listeners {
57 get {return TraceImpl.Listeners;}
60 [Conditional("DEBUG")]
61 public static void Assert (bool condition)
63 TraceImpl.Assert (condition);
66 [Conditional("DEBUG")]
67 public static void Assert (bool condition, string message)
69 TraceImpl.Assert (condition, message);
72 [Conditional("DEBUG")]
73 public static void Assert (bool condition, string message,
76 TraceImpl.Assert (condition, message, detailMessage);
79 [Conditional ("DEBUG")]
80 public static void Assert (bool condition, string message,
81 string detailMessageFormat, params object [] args)
84 // Return early to avoid the string formatting
87 TraceImpl.Assert (condition,
89 string.Format (detailMessageFormat, args));
92 [Conditional("DEBUG")]
93 public static void Close ()
98 [Conditional("DEBUG")]
99 public static void Fail (string message)
101 TraceImpl.Fail (message);
104 [Conditional("DEBUG")]
105 public static void Fail (string message, string detailMessage)
107 TraceImpl.Fail (message, detailMessage);
110 [Conditional("DEBUG")]
111 public static void Flush ()
116 [Conditional("DEBUG")]
117 public static void Indent ()
122 [Conditional("DEBUG")]
123 public static void Unindent ()
125 TraceImpl.Unindent ();
128 [Conditional("DEBUG")]
129 public static void Write (object value)
131 TraceImpl.Write (value);
134 [Conditional("DEBUG")]
135 public static void Write (string message)
137 TraceImpl.Write (message);
140 [Conditional("DEBUG")]
141 public static void Write (object value, string category)
143 TraceImpl.Write (value, category);
146 [Conditional("DEBUG")]
147 public static void Write (string message, string category)
149 TraceImpl.Write (message, category);
152 [Conditional("DEBUG")]
153 public static void WriteIf (bool condition, object value)
155 TraceImpl.WriteIf (condition, value);
158 [Conditional("DEBUG")]
159 public static void WriteIf (bool condition, string message)
161 TraceImpl.WriteIf (condition, message);
164 [Conditional("DEBUG")]
165 public static void WriteIf (bool condition, object value,
168 TraceImpl.WriteIf (condition, value, category);
171 [Conditional("DEBUG")]
172 public static void WriteIf (bool condition, string message,
175 TraceImpl.WriteIf (condition, message, category);
178 [Conditional("DEBUG")]
179 public static void WriteLine (object value)
181 TraceImpl.WriteLine (value);
184 [Conditional("DEBUG")]
185 public static void WriteLine (string message)
187 TraceImpl.WriteLine (message);
190 [Conditional("DEBUG")]
191 public static void WriteLine (string format, params object [] args)
193 TraceImpl.WriteLine (string.Format (format, args));
196 [Conditional("DEBUG")]
197 public static void WriteLine (object value, string category)
199 TraceImpl.WriteLine (value, category);
202 [Conditional("DEBUG")]
203 public static void WriteLine (string message, string category)
205 TraceImpl.WriteLine (message, category);
208 [Conditional("DEBUG")]
209 public static void WriteLineIf (bool condition, object value)
211 TraceImpl.WriteLineIf (condition, value);
214 [Conditional("DEBUG")]
215 public static void WriteLineIf (bool condition, string message)
217 TraceImpl.WriteLineIf (condition, message);
220 [Conditional("DEBUG")]
221 public static void WriteLineIf (bool condition, object value,
224 TraceImpl.WriteLineIf (condition, value, category);
227 [Conditional("DEBUG")]
228 public static void WriteLineIf (bool condition, string message,
231 TraceImpl.WriteLineIf (condition, message, category);
234 [Conditional("DEBUG")]
235 public static void Print (string message)
237 TraceImpl.WriteLine (message);
240 [Conditional("DEBUG")]
241 public static void Print (string format, params Object[] args)
243 TraceImpl.WriteLine (String.Format (format, args));