2 // Copied from System.Web.Util.WebTrace and changed a few lines
3 // Under MS runtime, Trace does not work because System.Web disables normal
7 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
9 // (C) 2002 Ximian, Inc (http://www.ximian.com)
13 using System
.Collections
;
14 using System
.Diagnostics
;
18 internal class WebTrace
20 static Stack ctxStack
;
22 static int indentation
; // Number of \t
26 ctxStack
= new Stack ();
29 [Conditional("WEBTRACE")]
30 static public void PushContext (string context
)
32 ctxStack
.Push (context
);
36 [Conditional("WEBTRACE")]
37 static public void PopContext ()
39 if (ctxStack
.Count
== 0)
46 static public string Context
49 if (ctxStack
.Count
== 0)
52 return (string) ctxStack
.Peek ();
56 static public bool StackTrace
60 set { trace = value; }
63 [Conditional("WEBTRACE")]
64 static public void WriteLine (string msg
)
66 Console
.WriteLine (Format (msg
));
69 [Conditional("WEBTRACE")]
70 static public void WriteLine (string msg
, object arg
)
72 Console
.WriteLine (Format (String
.Format (msg
, arg
)));
75 [Conditional("WEBTRACE")]
76 static public void WriteLine (string msg
, object arg1
, object arg2
)
78 Console
.WriteLine (Format (String
.Format (msg
, arg1
, arg2
)));
81 [Conditional("WEBTRACE")]
82 static public void WriteLine (string msg
, object arg1
, object arg2
, object arg3
)
84 Console
.WriteLine (Format (String
.Format (msg
, arg1
, arg2
, arg3
)));
87 [Conditional("WEBTRACE")]
88 static public void WriteLine (string msg
, params object [] args
)
90 Console
.WriteLine (Format (String
.Format (msg
, args
)));
99 return new String ('\t', indentation
);
103 static string Format (string msg
)
105 string ctx
= Tabs
+ Context
;
109 string result
= ctx
+ msg
;
111 result
+= "\n" + Environment
.StackTrace
;