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 ()
52 TraceConfig config = (TraceConfig) HttpContext.GetAppConfig (traceConfigPath);
57 enabled = config.Enabled;
58 local_only = config.LocalOnly;
59 page_output = config.PageOutput;
60 mode = config.TraceMode;
61 request_limit = config.RequestLimit;
65 get { return enabled; }
66 set { enabled = value; }
69 public bool LocalOnly {
70 get { return local_only; }
71 set { local_only = value; }
74 public bool PageOutput {
75 get { return page_output; }
76 set { page_output = value; }
79 public int RequestLimit {
80 get { return request_limit; }
82 if (request_limit == value)
84 TraceData[] swap = new TraceData [value];
85 Array.Copy (data, swap, (cur_item > value ? value : cur_item));
88 request_limit = value;
92 public TraceMode TraceMode {
97 public TraceData[] TraceData {
101 public void AddTraceData (TraceData item)
104 data = new TraceData [request_limit];
105 if (cur_item == request_limit)
107 data [cur_item++] = item;
115 Array.Clear (data, 0, data.Length);
119 public int ItemCount {
120 get { return cur_item; }