2 using System
.Diagnostics
;
7 /// Summary description for Logger.
11 private readonly static TraceSwitch Level
= new TraceSwitch( "NTrace", "NUnit internal trace" );
12 private readonly static string NL
= Environment
.NewLine
;
15 public static void Error( string message
)
17 if ( Level
.TraceError
)
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
)
38 WriteLine( ex
.ToString() );
44 public static void Warning( string message
)
46 if ( Level
.TraceWarning
)
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
);
64 public static void Info( string message
)
66 if ( Level
.TraceInfo
)
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
);
84 public static void Debug( string message
)
86 if ( Level
.TraceVerbose
)
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
);
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
);