aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/MainServer.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-09-20 22:36:47 +0100
committerJustin Clark-Casey (justincc)2012-09-20 23:17:44 +0100
commit387a1bb283c0c55178421f2c28b0d28a24dac7a1 (patch)
treea96c9196739525d59b4ad7de8d6a4b42d253b92b /OpenSim/Framework/Servers/MainServer.cs
parentDon't fail to create an IRC nick if nick randomization is disabled in the IRC... (diff)
downloadopensim-SC-387a1bb283c0c55178421f2c28b0d28a24dac7a1.zip
opensim-SC-387a1bb283c0c55178421f2c28b0d28a24dac7a1.tar.gz
opensim-SC-387a1bb283c0c55178421f2c28b0d28a24dac7a1.tar.bz2
opensim-SC-387a1bb283c0c55178421f2c28b0d28a24dac7a1.tar.xz
Add ability to turn on/off logging of outgoing HTTP requests flowing through WebUtil.
This is for debugging purposes. This is controlled via the "debug http" command which can already log incoming requests. This now gains a mandatory parameter of in, out or all to control what is logged. Log messages are also shortened and labelled and HTTP IN or HTTP OUT to be consistent with existing UDP PACKET IN and PACKET OUT messages.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Servers/MainServer.cs87
1 files changed, 65 insertions, 22 deletions
diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs
index 7402c73..b7a133e 100644
--- a/OpenSim/Framework/Servers/MainServer.cs
+++ b/OpenSim/Framework/Servers/MainServer.cs
@@ -48,9 +48,11 @@ namespace OpenSim.Framework.Servers
48 /// Control the printing of certain debug messages. 48 /// Control the printing of certain debug messages.
49 /// </summary> 49 /// </summary>
50 /// <remarks> 50 /// <remarks>
51 /// If DebugLevel >= 1, then short warnings are logged when receiving bad input data. 51 /// 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. 52 /// 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. 53 /// If DebugLevel >= 3 then short notices about all incoming non-poll HTTP requests are logged.
54 /// If DebugLevel >= 4 then the start of the body of incoming non-poll HTTP requests will be logged.
55 /// If DebugLevel >= 5 then the entire body of incoming non-poll HTTP requests will be logged.
54 /// </remarks> 56 /// </remarks>
55 public static int DebugLevel 57 public static int DebugLevel
56 { 58 {
@@ -102,7 +104,6 @@ namespace OpenSim.Framework.Servers
102 get { return new Dictionary<uint, BaseHttpServer>(m_Servers); } 104 get { return new Dictionary<uint, BaseHttpServer>(m_Servers); }
103 } 105 }
104 106
105
106 public static void RegisterHttpConsoleCommands(ICommandConsole console) 107 public static void RegisterHttpConsoleCommands(ICommandConsole console)
107 { 108 {
108 console.Commands.AddCommand( 109 console.Commands.AddCommand(
@@ -111,15 +112,18 @@ namespace OpenSim.Framework.Servers
111 "Show all registered http handlers", HandleShowHttpHandlersCommand); 112 "Show all registered http handlers", HandleShowHttpHandlersCommand);
112 113
113 console.Commands.AddCommand( 114 console.Commands.AddCommand(
114 "Debug", false, "debug http", "debug http [<level>]", 115 "Debug", false, "debug http", "debug http <in|out|all> [<level>]",
115 "Turn on inbound non-poll http request debugging.", 116 "Turn on http request logging.",
116 "If level <= 0, then no extra logging is done.\n" 117 "If in or all and\n"
117 + "If level >= 1, then short warnings are logged when receiving bad input data.\n" 118 + " level <= 0, then no extra logging is done.\n"
118 + "If level >= 2, then long warnings are logged when receiving bad input data.\n" 119 + " level >= 1, then short warnings are logged when receiving bad input data.\n"
119 + "If level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n" 120 + " level >= 2, then long warnings are logged when receiving bad input data.\n"
120 + "If level >= 4, then a sample from the beginning of the incoming data is logged.\n" 121 + " level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n"
121 + "If level >= 5, then the entire incoming data is logged.\n" 122 + " level >= 4, then a sample from the beginning of the incoming data is logged.\n"
122 + "If no level is specified then the current level is returned.", 123 + " level >= 5, then the entire incoming data is logged.\n"
124 + " no level is specified then the current level is returned.\n\n"
125 + "If out or all and\n"
126 + " level >= 3. then short notices about all outgoing requests going through WebUtil are logged.\n",
123 HandleDebugHttpCommand); 127 HandleDebugHttpCommand);
124 } 128 }
125 129
@@ -127,24 +131,63 @@ namespace OpenSim.Framework.Servers
127 /// Turn on some debugging values for OpenSim. 131 /// Turn on some debugging values for OpenSim.
128 /// </summary> 132 /// </summary>
129 /// <param name="args"></param> 133 /// <param name="args"></param>
130 private static void HandleDebugHttpCommand(string module, string[] args) 134 private static void HandleDebugHttpCommand(string module, string[] cmdparams)
131 { 135 {
132 if (args.Length == 3) 136 if (cmdparams.Length < 3)
133 { 137 {
138 MainConsole.Instance.Output("Usage: debug http <in|out|all> 0..5");
139 return;
140 }
141
142 bool inReqs = false;
143 bool outReqs = false;
144 bool allReqs = false;
145
146 string subCommand = cmdparams[2];
147
148 if (subCommand == "in")
149 inReqs = true;
150 else if (subCommand == "out")
151 outReqs = true;
152 else
153 allReqs = true;
154
155 if (cmdparams.Length >= 4)
156 {
157 string rawNewDebug = cmdparams[3];
134 int newDebug; 158 int newDebug;
135 if (int.TryParse(args[2], out newDebug)) 159
160 if (!int.TryParse(rawNewDebug, out newDebug))
161 {
162 MainConsole.Instance.OutputFormat("{0} is not a valid debug level", rawNewDebug);
163 return;
164 }
165
166 if (newDebug < 0 || newDebug > 5)
167 {
168 MainConsole.Instance.OutputFormat("{0} is outside the valid debug level range of 0..5", newDebug);
169 return;
170 }
171
172 if (allReqs || inReqs)
136 { 173 {
137 MainServer.DebugLevel = newDebug; 174 MainServer.DebugLevel = newDebug;
138 MainConsole.Instance.OutputFormat("Debug http level set to {0}", newDebug); 175 MainConsole.Instance.OutputFormat("In debug level set to {0}", newDebug);
176 }
177
178 if (allReqs || outReqs)
179 {
180 WebUtil.DebugLevel = newDebug;
181 MainConsole.Instance.OutputFormat("Out debug level set to {0}", newDebug);
139 } 182 }
140 }
141 else if (args.Length == 2)
142 {
143 MainConsole.Instance.OutputFormat("Current debug http level is {0}", MainServer.DebugLevel);
144 } 183 }
145 else 184 else
146 { 185 {
147 MainConsole.Instance.Output("Usage: debug http 0..5"); 186 if (allReqs || inReqs)
187 MainConsole.Instance.OutputFormat("Current in debug level is {0}", MainServer.DebugLevel);
188
189 if (allReqs || outReqs)
190 MainConsole.Instance.OutputFormat("Current out debug level is {0}", WebUtil.DebugLevel);
148 } 191 }
149 } 192 }
150 193