Dont index style nodes.
[beagle.git] / beagled / WebServices / WebServer / Tracing.cs
blob116dd70cfd68c3e9cb401363529ae9ed49bbf65e
1 //
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
4 // tracing.
5 //
6 // Authors:
7 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
8 //
9 // (C) 2002 Ximian, Inc (http://www.ximian.com)
12 using System;
13 using System.Collections;
14 using System.Diagnostics;
16 namespace Mono.ASPNET
18 internal class WebTrace
20 static Stack ctxStack;
21 static bool trace;
22 static int indentation; // Number of \t
24 static WebTrace ()
26 ctxStack = new Stack ();
29 [Conditional("WEBTRACE")]
30 static public void PushContext (string context)
32 ctxStack.Push (context);
33 indentation++;
36 [Conditional("WEBTRACE")]
37 static public void PopContext ()
39 if (ctxStack.Count == 0)
40 return;
42 indentation--;
43 ctxStack.Pop ();
46 static public string Context
48 get {
49 if (ctxStack.Count == 0)
50 return String.Empty;
52 return (string) ctxStack.Peek ();
56 static public bool StackTrace
58 get { return trace; }
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)));
93 static string Tabs
95 get {
96 if (indentation == 0)
97 return String.Empty;
99 return new String ('\t', indentation);
103 static string Format (string msg)
105 string ctx = Tabs + Context;
106 if (ctx.Length != 0)
107 ctx += ": ";
109 string result = ctx + msg;
110 if (trace)
111 result += "\n" + Environment.StackTrace;
113 return result;