File: NTrace.cs

package info (click to toggle)
mono 4.6.2.7+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 778,148 kB
  • ctags: 914,052
  • sloc: cs: 5,779,509; xml: 2,773,713; ansic: 432,645; sh: 14,749; makefile: 12,361; perl: 2,488; python: 1,434; cpp: 849; asm: 531; sql: 95; sed: 16; php: 1
file content (123 lines) | stat: -rw-r--r-- 2,581 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using System;
using System.Diagnostics;

namespace NUnit.Core
{
	/// <summary>
	/// Summary description for Logger.
	/// </summary>
	public class NTrace
	{
		private readonly static TraceSwitch Level = new TraceSwitch( "NTrace", "NUnit internal trace" ); 
		private readonly static string NL = Environment.NewLine;

		#region Error
		public static void Error( string message )
		{
			if ( Level.TraceError )
				WriteLine( message );
		}

		public static void Error( string message, string category )
		{
			if ( Level.TraceError )
				WriteLine( message, category );
		}

		public static void ErrorFormat( string message, params object[] args )
		{
			if ( Level.TraceError )
				WriteFormat( message, args );
		}

		public static void Error( string message, Exception ex )
		{
			if ( Level.TraceError )
			{
				WriteLine( message );
				WriteLine( ex.ToString() );
			}
		}
		#endregion

		#region Warning
		public static void Warning( string message )
		{
			if ( Level.TraceWarning )
				WriteLine( message );
		}

		public static void Warning( string message, string category )
		{
			if ( Level.TraceWarning )
				WriteLine( message, category );
		}

		public static void WarningFormat( string message, params object[] args )
		{
			if ( Level.TraceWarning )
				WriteFormat( message, args );
		}
		#endregion

		#region Info
		public static void Info( string message )
		{
			if ( Level.TraceInfo )
				WriteLine( message );
		}

		public static void Info( string message, string category )
		{
			if ( Level.TraceInfo )
				WriteLine( message, category );
		}

		public static void InfoFormat( string message, params object[] args )
		{
			if ( Level.TraceInfo )
				WriteFormat( message, args );
		}
		#endregion

		#region Debug
		public static void Debug( string message )
		{
			if ( Level.TraceVerbose )
				WriteLine( message );
		}

		public static void Debug( string message, string category )
		{
			if ( Level.TraceVerbose )
				WriteLine( message, category );
		}

		public static void DebugFormat( string message, params object[] args )
		{
			if ( Level.TraceVerbose )
				WriteFormat( message, args );
		}
		#endregion

		#region Helper Methods
		private static void WriteLine( string message )
		{
			Trace.WriteLine( message );
		}

		private static void WriteLine( string message, string category )
		{
			Trace.WriteLine( message, category );
		}

		private static void WriteFormat( string format, params object[] args )
		{
			string message = string.Format( format, args );
			Trace.WriteLine( message );
		}
		#endregion

		private NTrace() { }
	}
}