aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
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
parentDon't fail to create an IRC nick if nick randomization is disabled in the IRC... (diff)
downloadopensim-SC_OLD-387a1bb283c0c55178421f2c28b0d28a24dac7a1.zip
opensim-SC_OLD-387a1bb283c0c55178421f2c28b0d28a24dac7a1.tar.gz
opensim-SC_OLD-387a1bb283c0c55178421f2c28b0d28a24dac7a1.tar.bz2
opensim-SC_OLD-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/HttpServer/BaseHttpServer.cs10
-rw-r--r--OpenSim/Framework/Servers/MainServer.cs87
-rw-r--r--OpenSim/Framework/WebUtil.cs41
3 files changed, 103 insertions, 35 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 43a19fa..f93b3dd 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -529,7 +529,7 @@ namespace OpenSim.Framework.Servers.HttpServer
529 529
530 if (DebugLevel >= 3) 530 if (DebugLevel >= 3)
531 m_log.DebugFormat( 531 m_log.DebugFormat(
532 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", 532 "[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2}",
533 request.ContentType, request.HttpMethod, request.Url.PathAndQuery); 533 request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
534 534
535 buffer = HandleHTTPRequest(request, response); 535 buffer = HandleHTTPRequest(request, response);
@@ -541,7 +541,7 @@ namespace OpenSim.Framework.Servers.HttpServer
541 541
542 if (DebugLevel >= 3) 542 if (DebugLevel >= 3)
543 m_log.DebugFormat( 543 m_log.DebugFormat(
544 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", 544 "[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2}",
545 request.ContentType, request.HttpMethod, request.Url.PathAndQuery); 545 request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
546 546
547 buffer = HandleLLSDRequests(request, response); 547 buffer = HandleLLSDRequests(request, response);
@@ -649,7 +649,7 @@ namespace OpenSim.Framework.Servers.HttpServer
649 private void LogIncomingToStreamHandler(OSHttpRequest request, IRequestHandler requestHandler) 649 private void LogIncomingToStreamHandler(OSHttpRequest request, IRequestHandler requestHandler)
650 { 650 {
651 m_log.DebugFormat( 651 m_log.DebugFormat(
652 "[BASE HTTP SERVER]: Found stream handler for {0} {1} {2} {3}", 652 "[BASE HTTP SERVER]: HTTP IN stream handler {0} {1} {2} {3}",
653 request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description); 653 request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description);
654 654
655 if (DebugLevel >= 4) 655 if (DebugLevel >= 4)
@@ -659,7 +659,7 @@ namespace OpenSim.Framework.Servers.HttpServer
659 private void LogIncomingToContentTypeHandler(OSHttpRequest request) 659 private void LogIncomingToContentTypeHandler(OSHttpRequest request)
660 { 660 {
661 m_log.DebugFormat( 661 m_log.DebugFormat(
662 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", 662 "[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2}",
663 request.ContentType, request.HttpMethod, request.Url.PathAndQuery); 663 request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
664 664
665 if (DebugLevel >= 4) 665 if (DebugLevel >= 4)
@@ -669,7 +669,7 @@ namespace OpenSim.Framework.Servers.HttpServer
669 private void LogIncomingToXmlRpcHandler(OSHttpRequest request) 669 private void LogIncomingToXmlRpcHandler(OSHttpRequest request)
670 { 670 {
671 m_log.DebugFormat( 671 m_log.DebugFormat(
672 "[BASE HTTP SERVER]: Assuming a generic XMLRPC request for {0} {1}", 672 "[BASE HTTP SERVER]: HTTP IN assumed generic XMLRPC request {0} {1}",
673 request.HttpMethod, request.Url.PathAndQuery); 673 request.HttpMethod, request.Url.PathAndQuery);
674 674
675 if (DebugLevel >= 4) 675 if (DebugLevel >= 4)
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
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs
index 2aa4af5..7c4e852 100644
--- a/OpenSim/Framework/WebUtil.cs
+++ b/OpenSim/Framework/WebUtil.cs
@@ -54,6 +54,14 @@ namespace OpenSim.Framework
54 MethodBase.GetCurrentMethod().DeclaringType); 54 MethodBase.GetCurrentMethod().DeclaringType);
55 55
56 /// <summary> 56 /// <summary>
57 /// Control the printing of certain debug messages.
58 /// </summary>
59 /// <remarks>
60 /// If DebugLevel >= 3 then short notices about outgoing HTTP requests are logged.
61 /// </remarks>
62 public static int DebugLevel { get; set; }
63
64 /// <summary>
57 /// Request number for diagnostic purposes. 65 /// Request number for diagnostic purposes.
58 /// </summary> 66 /// </summary>
59 public static int RequestNumber = 0; 67 public static int RequestNumber = 0;
@@ -146,7 +154,11 @@ namespace OpenSim.Framework
146 private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed) 154 private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed)
147 { 155 {
148 int reqnum = RequestNumber++; 156 int reqnum = RequestNumber++;
149 // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); 157
158 if (DebugLevel >= 3)
159 m_log.DebugFormat(
160 "[WEB UTIL]: HTTP OUT {0} ServiceOSD {1} {2} (timeout {3}, compressed {4})",
161 reqnum, method, url, timeout, compressed);
150 162
151 string errorMessage = "unknown error"; 163 string errorMessage = "unknown error";
152 int tickstart = Util.EnvironmentTickCount(); 164 int tickstart = Util.EnvironmentTickCount();
@@ -317,7 +329,11 @@ namespace OpenSim.Framework
317 { 329 {
318 int reqnum = RequestNumber++; 330 int reqnum = RequestNumber++;
319 string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown"; 331 string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown";
320 // m_log.DebugFormat("[WEB UTIL]: <{0}> start form request for {1}, method {2}",reqnum,url,method); 332
333 if (DebugLevel >= 3)
334 m_log.DebugFormat(
335 "[WEB UTIL]: HTTP OUT {0} ServiceForm {1} {2} (timeout {3})",
336 reqnum, method, url, timeout);
321 337
322 string errorMessage = "unknown error"; 338 string errorMessage = "unknown error";
323 int tickstart = Util.EnvironmentTickCount(); 339 int tickstart = Util.EnvironmentTickCount();
@@ -643,7 +659,6 @@ namespace OpenSim.Framework
643 /// <returns></returns> 659 /// <returns></returns>
644 public static string[] GetPreferredImageTypes(string accept) 660 public static string[] GetPreferredImageTypes(string accept)
645 { 661 {
646
647 if (accept == null || accept == string.Empty) 662 if (accept == null || accept == string.Empty)
648 return new string[0]; 663 return new string[0];
649 664
@@ -695,13 +710,15 @@ namespace OpenSim.Framework
695 string requestUrl, TRequest obj, Action<TResponse> action) 710 string requestUrl, TRequest obj, Action<TResponse> action)
696 { 711 {
697 int reqnum = WebUtil.RequestNumber++; 712 int reqnum = WebUtil.RequestNumber++;
698 // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); 713
714 if (WebUtil.DebugLevel >= 3)
715 m_log.DebugFormat(
716 "[WEB UTIL]: HTTP OUT {0} AsynchronousRequestObject {1} {2}",
717 reqnum, verb, requestUrl);
699 718
700 int tickstart = Util.EnvironmentTickCount(); 719 int tickstart = Util.EnvironmentTickCount();
701 int tickdata = 0; 720 int tickdata = 0;
702 721
703 // m_log.DebugFormat("[ASYNC REQUEST]: Starting {0} {1}", verb, requestUrl);
704
705 Type type = typeof(TRequest); 722 Type type = typeof(TRequest);
706 723
707 WebRequest request = WebRequest.Create(requestUrl); 724 WebRequest request = WebRequest.Create(requestUrl);
@@ -882,7 +899,11 @@ namespace OpenSim.Framework
882 public static string MakeRequest(string verb, string requestUrl, string obj) 899 public static string MakeRequest(string verb, string requestUrl, string obj)
883 { 900 {
884 int reqnum = WebUtil.RequestNumber++; 901 int reqnum = WebUtil.RequestNumber++;
885 // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); 902
903 if (WebUtil.DebugLevel >= 3)
904 m_log.DebugFormat(
905 "[WEB UTIL]: HTTP OUT {0} SynchronousRestForms {1} {2}",
906 reqnum, verb, requestUrl);
886 907
887 int tickstart = Util.EnvironmentTickCount(); 908 int tickstart = Util.EnvironmentTickCount();
888 int tickdata = 0; 909 int tickdata = 0;
@@ -998,7 +1019,11 @@ namespace OpenSim.Framework
998 public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj) 1019 public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj)
999 { 1020 {
1000 int reqnum = WebUtil.RequestNumber++; 1021 int reqnum = WebUtil.RequestNumber++;
1001 // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); 1022
1023 if (WebUtil.DebugLevel >= 3)
1024 m_log.DebugFormat(
1025 "[WEB UTIL]: HTTP OUT {0} SynchronousRestObject {1} {2}",
1026 reqnum, verb, requestUrl);
1002 1027
1003 int tickstart = Util.EnvironmentTickCount(); 1028 int tickstart = Util.EnvironmentTickCount();
1004 int tickdata = 0; 1029 int tickdata = 0;