2 // System.Web.TraceManager
5 // Jackson Harper (jackson@ximian.com)
7 // (C) 2004 Novell, Inc (http://www.novell.com)
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:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
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.
33 using System.Collections;
34 using System.Web.Configuration;
36 namespace System.Web {
38 internal class TraceManager {
40 private static string traceConfigPath = "system.web/trace";
41 private bool enabled = false;
42 private bool local_only = true;
43 private bool page_output = false;
44 private TraceMode mode;
45 private int request_limit = 10;
48 private TraceData[] data;
50 public TraceManager ()
53 TraceSection config = WebConfigurationManager.GetSection ("system.web/trace") as TraceSection;
55 config = new TraceSection ();
57 TraceConfig config = (TraceConfig) HttpContext.GetAppConfig (traceConfigPath);
63 enabled = config.Enabled;
64 local_only = config.LocalOnly;
65 page_output = config.PageOutput;
67 if (config.TraceMode == TraceDisplayMode.SortByTime)
68 mode = TraceMode.SortByTime;
70 mode = TraceMode.SortByCategory;
72 mode = config.TraceMode;
74 request_limit = config.RequestLimit;
78 get { return enabled; }
79 set { enabled = value; }
82 public bool LocalOnly {
83 get { return local_only; }
84 set { local_only = value; }
87 public bool PageOutput {
88 get { return page_output; }
89 set { page_output = value; }
92 public int RequestLimit {
93 get { return request_limit; }
95 if (request_limit == value)
97 TraceData[] swap = new TraceData [value];
98 Array.Copy (data, swap, (cur_item > value ? value : cur_item));
101 request_limit = value;
105 public TraceMode TraceMode {
107 set { mode = value; }
110 public TraceData[] TraceData {
114 public void AddTraceData (TraceData item)
117 data = new TraceData [request_limit];
118 if (cur_item == request_limit)
120 data [cur_item++] = item;
128 Array.Clear (data, 0, data.Length);
132 public int ItemCount {
133 get { return cur_item; }