diff options
Diffstat (limited to 'OpenSim/Framework/Servers/MainServer.cs')
-rw-r--r-- | OpenSim/Framework/Servers/MainServer.cs | 148 |
1 files changed, 19 insertions, 129 deletions
diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index ae7d515..8dc0e3a 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs | |||
@@ -29,7 +29,6 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Net; | 31 | using System.Net; |
32 | using System.Text; | ||
33 | using log4net; | 32 | using log4net; |
34 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Console; | 34 | using OpenSim.Framework.Console; |
@@ -48,12 +47,9 @@ namespace OpenSim.Framework.Servers | |||
48 | /// Control the printing of certain debug messages. | 47 | /// Control the printing of certain debug messages. |
49 | /// </summary> | 48 | /// </summary> |
50 | /// <remarks> | 49 | /// <remarks> |
51 | /// If DebugLevel >= 1 then short warnings are logged when receiving bad input data. | 50 | /// If DebugLevel >= 1, then short warnings are logged when receiving bad input data. |
52 | /// If DebugLevel >= 2 then long warnings are logged when receiving bad input data. | 51 | /// If DebugLevel >= 2, then long warnings are logged when receiving bad input data. |
53 | /// If DebugLevel >= 3 then short notices about all incoming non-poll HTTP requests are logged. | 52 | /// If DebugLevel >= 3, then short notices about all incoming non-poll HTTP requests are logged. |
54 | /// If DebugLevel >= 4 then the time taken to fulfill the request is logged. | ||
55 | /// If DebugLevel >= 5 then the start of the body of incoming non-poll HTTP requests will be logged. | ||
56 | /// If DebugLevel >= 6 then the entire body of incoming non-poll HTTP requests will be logged. | ||
57 | /// </remarks> | 53 | /// </remarks> |
58 | public static int DebugLevel | 54 | public static int DebugLevel |
59 | { | 55 | { |
@@ -105,28 +101,17 @@ namespace OpenSim.Framework.Servers | |||
105 | get { return new Dictionary<uint, BaseHttpServer>(m_Servers); } | 101 | get { return new Dictionary<uint, BaseHttpServer>(m_Servers); } |
106 | } | 102 | } |
107 | 103 | ||
104 | |||
108 | public static void RegisterHttpConsoleCommands(ICommandConsole console) | 105 | public static void RegisterHttpConsoleCommands(ICommandConsole console) |
109 | { | 106 | { |
110 | console.Commands.AddCommand( | 107 | console.Commands.AddCommand( |
111 | "Comms", false, "show http-handlers", | 108 | "Debug", false, "debug http", "debug http [<level>]", |
112 | "show http-handlers", | 109 | "Turn on inbound non-poll http request debugging.", |
113 | "Show all registered http handlers", HandleShowHttpHandlersCommand); | 110 | "If level <= 0, then no extra logging is done.\n" |
114 | 111 | + "If level >= 1, then short warnings are logged when receiving bad input data.\n" | |
115 | console.Commands.AddCommand( | 112 | + "If level >= 2, then long warnings are logged when receiving bad input data.\n" |
116 | "Debug", false, "debug http", "debug http <in|out|all> [<level>]", | 113 | + "If level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n" |
117 | "Turn on http request logging.", | 114 | + "If no level is specified then the current level is returned.", |
118 | "If in or all and\n" | ||
119 | + " level <= 0 then no extra logging is done.\n" | ||
120 | + " level >= 1 then short warnings are logged when receiving bad input data.\n" | ||
121 | + " level >= 2 then long warnings are logged when receiving bad input data.\n" | ||
122 | + " level >= 3 then short notices about all incoming non-poll HTTP requests are logged.\n" | ||
123 | + " level >= 4 then the time taken to fulfill the request is logged.\n" | ||
124 | + " level >= 5 then a sample from the beginning of the incoming data is logged.\n" | ||
125 | + " level >= 6 then the entire incoming data is logged.\n" | ||
126 | + " no level is specified then the current level is returned.\n\n" | ||
127 | + "If out or all and\n" | ||
128 | + " level >= 3 then short notices about all outgoing requests going through WebUtil are logged.\n" | ||
129 | + " level >= 4 then the time taken to fulfill the request is logged.\n", | ||
130 | HandleDebugHttpCommand); | 115 | HandleDebugHttpCommand); |
131 | } | 116 | } |
132 | 117 | ||
@@ -134,120 +119,25 @@ namespace OpenSim.Framework.Servers | |||
134 | /// Turn on some debugging values for OpenSim. | 119 | /// Turn on some debugging values for OpenSim. |
135 | /// </summary> | 120 | /// </summary> |
136 | /// <param name="args"></param> | 121 | /// <param name="args"></param> |
137 | private static void HandleDebugHttpCommand(string module, string[] cmdparams) | 122 | private static void HandleDebugHttpCommand(string module, string[] args) |
138 | { | 123 | { |
139 | if (cmdparams.Length < 3) | 124 | if (args.Length == 3) |
140 | { | ||
141 | MainConsole.Instance.Output("Usage: debug http <in|out|all> 0..6"); | ||
142 | return; | ||
143 | } | ||
144 | |||
145 | bool inReqs = false; | ||
146 | bool outReqs = false; | ||
147 | bool allReqs = false; | ||
148 | |||
149 | string subCommand = cmdparams[2]; | ||
150 | |||
151 | if (subCommand.ToLower() == "in") | ||
152 | { | ||
153 | inReqs = true; | ||
154 | } | ||
155 | else if (subCommand.ToLower() == "out") | ||
156 | { | ||
157 | outReqs = true; | ||
158 | } | ||
159 | else if (subCommand.ToLower() == "all") | ||
160 | { | ||
161 | allReqs = true; | ||
162 | } | ||
163 | else | ||
164 | { | 125 | { |
165 | MainConsole.Instance.Output("You must specify in, out or all"); | ||
166 | return; | ||
167 | } | ||
168 | |||
169 | if (cmdparams.Length >= 4) | ||
170 | { | ||
171 | string rawNewDebug = cmdparams[3]; | ||
172 | int newDebug; | 126 | int newDebug; |
173 | 127 | if (int.TryParse(args[2], out newDebug)) | |
174 | if (!int.TryParse(rawNewDebug, out newDebug)) | ||
175 | { | ||
176 | MainConsole.Instance.OutputFormat("{0} is not a valid debug level", rawNewDebug); | ||
177 | return; | ||
178 | } | ||
179 | |||
180 | if (newDebug < 0 || newDebug > 6) | ||
181 | { | ||
182 | MainConsole.Instance.OutputFormat("{0} is outside the valid debug level range of 0..6", newDebug); | ||
183 | return; | ||
184 | } | ||
185 | |||
186 | if (allReqs || inReqs) | ||
187 | { | 128 | { |
188 | MainServer.DebugLevel = newDebug; | 129 | MainServer.DebugLevel = newDebug; |
189 | MainConsole.Instance.OutputFormat("IN debug level set to {0}", newDebug); | 130 | MainConsole.Instance.OutputFormat("Debug http level set to {0}", newDebug); |
190 | } | ||
191 | |||
192 | if (allReqs || outReqs) | ||
193 | { | ||
194 | WebUtil.DebugLevel = newDebug; | ||
195 | MainConsole.Instance.OutputFormat("OUT debug level set to {0}", newDebug); | ||
196 | } | 131 | } |
197 | } | 132 | } |
198 | else | 133 | else if (args.Length == 2) |
199 | { | 134 | { |
200 | if (allReqs || inReqs) | 135 | MainConsole.Instance.OutputFormat("Current debug http level is {0}", MainServer.DebugLevel); |
201 | MainConsole.Instance.OutputFormat("Current IN debug level is {0}", MainServer.DebugLevel); | ||
202 | |||
203 | if (allReqs || outReqs) | ||
204 | MainConsole.Instance.OutputFormat("Current OUT debug level is {0}", WebUtil.DebugLevel); | ||
205 | } | 136 | } |
206 | } | 137 | else |
207 | |||
208 | private static void HandleShowHttpHandlersCommand(string module, string[] args) | ||
209 | { | ||
210 | if (args.Length != 2) | ||
211 | { | ||
212 | MainConsole.Instance.Output("Usage: show http-handlers"); | ||
213 | return; | ||
214 | } | ||
215 | |||
216 | StringBuilder handlers = new StringBuilder(); | ||
217 | |||
218 | lock (m_Servers) | ||
219 | { | 138 | { |
220 | foreach (BaseHttpServer httpServer in m_Servers.Values) | 139 | MainConsole.Instance.Output("Usage: debug http 0..3"); |
221 | { | ||
222 | handlers.AppendFormat( | ||
223 | "Registered HTTP Handlers for server at {0}:{1}\n", httpServer.ListenIPAddress, httpServer.Port); | ||
224 | |||
225 | handlers.AppendFormat("* XMLRPC:\n"); | ||
226 | foreach (String s in httpServer.GetXmlRpcHandlerKeys()) | ||
227 | handlers.AppendFormat("\t{0}\n", s); | ||
228 | |||
229 | handlers.AppendFormat("* HTTP:\n"); | ||
230 | List<String> poll = httpServer.GetPollServiceHandlerKeys(); | ||
231 | foreach (String s in httpServer.GetHTTPHandlerKeys()) | ||
232 | handlers.AppendFormat("\t{0} {1}\n", s, (poll.Contains(s) ? "(poll service)" : string.Empty)); | ||
233 | |||
234 | // handlers.AppendFormat("* Agent:\n"); | ||
235 | // foreach (String s in httpServer.GetAgentHandlerKeys()) | ||
236 | // handlers.AppendFormat("\t{0}\n", s); | ||
237 | |||
238 | handlers.AppendFormat("* LLSD:\n"); | ||
239 | foreach (String s in httpServer.GetLLSDHandlerKeys()) | ||
240 | handlers.AppendFormat("\t{0}\n", s); | ||
241 | |||
242 | handlers.AppendFormat("* StreamHandlers ({0}):\n", httpServer.GetStreamHandlerKeys().Count); | ||
243 | foreach (String s in httpServer.GetStreamHandlerKeys()) | ||
244 | handlers.AppendFormat("\t{0}\n", s); | ||
245 | |||
246 | handlers.Append("\n"); | ||
247 | } | ||
248 | } | 140 | } |
249 | |||
250 | MainConsole.Instance.Output(handlers.ToString()); | ||
251 | } | 141 | } |
252 | 142 | ||
253 | /// <summary> | 143 | /// <summary> |