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
{
45 [MonoNotSupported ("")]
46 public static void Refresh ()
48 throw new NotImplementedException ();
52 public static bool AutoFlush
{
53 get {return TraceImpl.AutoFlush;}
54 set {TraceImpl.AutoFlush = value;}
57 public static int IndentLevel
{
58 get {return TraceImpl.IndentLevel;}
59 set {TraceImpl.IndentLevel = value;}
62 public static int IndentSize
{
63 get {return TraceImpl.IndentSize;}
64 set {TraceImpl.IndentSize = value;}
67 public static TraceListenerCollection Listeners
{
68 get {return TraceImpl.Listeners;}
72 public static CorrelationManager CorrelationManager
{
73 get { return TraceImpl.CorrelationManager; }
80 static bool UseGlobalLock
{
81 get { return TraceImpl.UseGlobalLock; }
82 set { TraceImpl.UseGlobalLock = value; }
85 [Conditional("TRACE")]
86 public static void Assert (bool condition
)
88 TraceImpl
.Assert (condition
);
91 [Conditional("TRACE")]
92 public static void Assert (bool condition
, string message
)
94 TraceImpl
.Assert (condition
, message
);
97 [Conditional("TRACE")]
98 public static void Assert (bool condition
, string message
,
101 TraceImpl
.Assert (condition
, message
, detailMessage
);
104 [Conditional("TRACE")]
105 public static void Close ()
110 [Conditional("TRACE")]
111 public static void Fail (string message
)
113 TraceImpl
.Fail (message
);
116 [Conditional("TRACE")]
117 public static void Fail (string message
, string detailMessage
)
119 TraceImpl
.Fail (message
, detailMessage
);
122 [Conditional("TRACE")]
123 public static void Flush ()
128 [Conditional("TRACE")]
129 public static void Indent ()
134 [Conditional("TRACE")]
135 public static void Unindent ()
137 TraceImpl
.Unindent ();
140 [Conditional("TRACE")]
141 public static void Write (object value)
143 TraceImpl
.Write (value);
146 [Conditional("TRACE")]
147 public static void Write (string message
)
149 TraceImpl
.Write (message
);
152 [Conditional("TRACE")]
153 public static void Write (object value, string category
)
155 TraceImpl
.Write (value, category
);
158 [Conditional("TRACE")]
159 public static void Write (string message
, string category
)
161 TraceImpl
.Write (message
, category
);
164 [Conditional("TRACE")]
165 public static void WriteIf (bool condition
, object value)
167 TraceImpl
.WriteIf (condition
, value);
170 [Conditional("TRACE")]
171 public static void WriteIf (bool condition
, string message
)
173 TraceImpl
.WriteIf (condition
, message
);
176 [Conditional("TRACE")]
177 public static void WriteIf (bool condition
, object value,
180 TraceImpl
.WriteIf (condition
, value, category
);
183 [Conditional("TRACE")]
184 public static void WriteIf (bool condition
, string message
,
187 TraceImpl
.WriteIf (condition
, message
, category
);
190 [Conditional("TRACE")]
191 public static void WriteLine (object value)
193 TraceImpl
.WriteLine (value);
196 [Conditional("TRACE")]
197 public static void WriteLine (string message
)
199 TraceImpl
.WriteLine (message
);
202 [Conditional("TRACE")]
203 public static void WriteLine (object value, string category
)
205 TraceImpl
.WriteLine (value, category
);
208 [Conditional("TRACE")]
209 public static void WriteLine (string message
, string category
)
211 TraceImpl
.WriteLine (message
, category
);
214 [Conditional("TRACE")]
215 public static void WriteLineIf (bool condition
, object value)
217 TraceImpl
.WriteLineIf (condition
, value);
220 [Conditional("TRACE")]
221 public static void WriteLineIf (bool condition
, string message
)
223 TraceImpl
.WriteLineIf (condition
, message
);
226 [Conditional("TRACE")]
227 public static void WriteLineIf (bool condition
, object value,
230 TraceImpl
.WriteLineIf (condition
, value, category
);
233 [Conditional("TRACE")]
234 public static void WriteLineIf (bool condition
, string message
,
237 TraceImpl
.WriteLineIf (condition
, message
, category
);
241 static void DoTrace (string kind
, Assembly report
, string message
)
243 TraceImpl
.WriteLine (String
.Format ("{0} {1} : 0 : {2}", report
.Location
, kind
, message
));
246 [Conditional("TRACE")]
247 public static void TraceError (string message
)
249 DoTrace ("Error", Assembly
.GetCallingAssembly (), message
);
252 [Conditional("TRACE")]
253 public static void TraceError (string message
, params object [] args
)
255 DoTrace ("Error", Assembly
.GetCallingAssembly (), String
.Format (message
, args
));
258 [Conditional("TRACE")]
259 public static void TraceInformation (string message
)
261 DoTrace ("Information", Assembly
.GetCallingAssembly (), message
);
264 [Conditional("TRACE")]
265 public static void TraceInformation (string message
, params object [] args
)
267 DoTrace ("Information", Assembly
.GetCallingAssembly (), String
.Format (message
, args
));
270 [Conditional("TRACE")]
271 public static void TraceWarning (string message
)
273 DoTrace ("Warning", Assembly
.GetCallingAssembly (), message
);
276 [Conditional("TRACE")]
277 public static void TraceWarning (string message
, params object [] args
)
279 DoTrace ("Warning", Assembly
.GetCallingAssembly (), String
.Format (message
, args
));