2
/****************************************************************************
4
| Copyright (c) 2007 Novell, Inc.
7
| This program is free software; you can redistribute it and/or
8
| modify it under the terms of version 2 of the GNU General Public License as
9
| published by the Free Software Foundation.
11
| This program is distributed in the hope that it will be useful,
12
| but WITHOUT ANY WARRANTY; without even the implied warranty of
13
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
| GNU General Public License for more details.
16
| You should have received a copy of the GNU General Public License
17
| along with this program; if not, contact Novell, Inc.
19
| To contact Novell about this file by physical or electronic mail,
20
| you may find current contact information at www.novell.com
23
| Gonzalo Paniagua Javier (gonzalo@ximian.com)
24
|***************************************************************************/
28
using System.Collections;
29
using System.Diagnostics;
33
internal class WebTrace
35
static Stack ctxStack;
37
static int indentation; // Number of \t
41
ctxStack = new Stack ();
44
[Conditional("WEBTRACE")]
45
static public void PushContext (string context)
47
ctxStack.Push (context);
51
[Conditional("WEBTRACE")]
52
static public void PopContext ()
54
if (ctxStack.Count == 0)
61
static public string Context
64
if (ctxStack.Count == 0)
67
return (string) ctxStack.Peek ();
71
static public bool StackTrace
75
set { trace = value; }
78
[Conditional("WEBTRACE")]
79
static public void WriteLine (string msg)
81
Console.WriteLine (Format (msg));
84
[Conditional("WEBTRACE")]
85
static public void WriteLine (string msg, object arg)
87
Console.WriteLine (Format (String.Format (msg, arg)));
90
[Conditional("WEBTRACE")]
91
static public void WriteLine (string msg, object arg1, object arg2)
93
Console.WriteLine (Format (String.Format (msg, arg1, arg2)));
96
[Conditional("WEBTRACE")]
97
static public void WriteLine (string msg, object arg1, object arg2, object arg3)
99
Console.WriteLine (Format (String.Format (msg, arg1, arg2, arg3)));
102
[Conditional("WEBTRACE")]
103
static public void WriteLine (string msg, params object [] args)
105
Console.WriteLine (Format (String.Format (msg, args)));
111
if (indentation == 0)
114
return new String ('\t', indentation);
118
static string Format (string msg)
120
string ctx = Tabs + Context;
124
string result = ctx + msg;
126
result += "\n" + Environment.StackTrace;