(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.Web / System.Web.Util / WebTrace.cs
blobc81a3354faae8e2c2c79ff4028e69c1981a8c473
1 //
2 // System.Web.Util.WebTrace
3 //
4 // Authors:
5 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
6 //
7 // (C) 2002 Ximian, Inc (http://www.ximian.com)
8 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 //
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System.Collections;
32 using System.Diagnostics;
34 namespace System.Web.Util
36 internal class WebTrace
38 static Stack ctxStack;
39 static bool trace;
41 static WebTrace ()
43 ctxStack = new Stack ();
46 [Conditional("WEBTRACE")]
47 static public void PushContext (string context)
49 ctxStack.Push (context);
50 Trace.Indent ();
53 [Conditional("WEBTRACE")]
54 static public void PopContext ()
56 if (ctxStack.Count == 0)
57 return;
59 Trace.Unindent ();
60 ctxStack.Pop ();
63 static public string Context
65 get {
66 if (ctxStack.Count == 0)
67 return "No context";
69 return (string) ctxStack.Peek ();
73 static public bool StackTrace
75 get { return trace; }
77 set { trace = value; }
80 [Conditional("WEBTRACE")]
81 static public void WriteLine (string msg)
83 Trace.WriteLine (Format (msg));
86 [Conditional("WEBTRACE")]
87 static public void WriteLine (string msg, object arg)
89 Trace.WriteLine (Format (String.Format (msg, arg)));
92 [Conditional("WEBTRACE")]
93 static public void WriteLine (string msg, object arg1, object arg2)
95 Trace.WriteLine (Format (String.Format (msg, arg1, arg2)));
98 [Conditional("WEBTRACE")]
99 static public void WriteLine (string msg, object arg1, object arg2, object arg3)
101 Trace.WriteLine (Format (String.Format (msg, arg1, arg2, arg3)));
104 [Conditional("WEBTRACE")]
105 static public void WriteLine (string msg, params object [] args)
107 Trace.WriteLine (Format (String.Format (msg, args)));
110 static string Format (string msg)
112 if (trace)
113 return String.Format ("{0}: {1}\n{2}", Context, msg, Environment.StackTrace);
114 else
115 return String.Format ("{0}: {1}", Context, msg);