2010-06-03 Jb Evain <jbevain@novell.com>
[mcs.git] / nunit24 / NUnitCore / core / NTrace.cs
blobcd90fd01f1fe790dd4cc6c52b0b31928368ed789
1 using System;
2 using System.Diagnostics;
4 namespace NUnit.Core
6 /// <summary>
7 /// Summary description for Logger.
8 /// </summary>
9 public class NTrace
11 private readonly static TraceSwitch Level = new TraceSwitch( "NTrace", "NUnit internal trace" );
12 private readonly static string NL = Environment.NewLine;
14 #region Error
15 public static void Error( string message )
17 if ( Level.TraceError )
18 WriteLine( message );
21 public static void Error( string message, string category )
23 if ( Level.TraceError )
24 WriteLine( message, category );
27 public static void ErrorFormat( string message, params object[] args )
29 if ( Level.TraceError )
30 WriteFormat( message, args );
33 public static void Error( string message, Exception ex )
35 if ( Level.TraceError )
37 WriteLine( message );
38 WriteLine( ex.ToString() );
41 #endregion
43 #region Warning
44 public static void Warning( string message )
46 if ( Level.TraceWarning )
47 WriteLine( message );
50 public static void Warning( string message, string category )
52 if ( Level.TraceWarning )
53 WriteLine( message, category );
56 public static void WarningFormat( string message, params object[] args )
58 if ( Level.TraceWarning )
59 WriteFormat( message, args );
61 #endregion
63 #region Info
64 public static void Info( string message )
66 if ( Level.TraceInfo )
67 WriteLine( message );
70 public static void Info( string message, string category )
72 if ( Level.TraceInfo )
73 WriteLine( message, category );
76 public static void InfoFormat( string message, params object[] args )
78 if ( Level.TraceInfo )
79 WriteFormat( message, args );
81 #endregion
83 #region Debug
84 public static void Debug( string message )
86 if ( Level.TraceVerbose )
87 WriteLine( message );
90 public static void Debug( string message, string category )
92 if ( Level.TraceVerbose )
93 WriteLine( message, category );
96 public static void DebugFormat( string message, params object[] args )
98 if ( Level.TraceVerbose )
99 WriteFormat( message, args );
101 #endregion
103 #region Helper Methods
104 private static void WriteLine( string message )
106 Trace.WriteLine( message );
109 private static void WriteLine( string message, string category )
111 Trace.WriteLine( message, category );
114 private static void WriteFormat( string format, params object[] args )
116 string message = string.Format( format, args );
117 Trace.WriteLine( message );
119 #endregion
121 private NTrace() { }