diff options
author | Justin Clark-Casey (justincc) | 2012-09-20 22:36:47 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-09-20 23:17:44 +0100 |
commit | 387a1bb283c0c55178421f2c28b0d28a24dac7a1 (patch) | |
tree | a96c9196739525d59b4ad7de8d6a4b42d253b92b /OpenSim/Framework/WebUtil.cs | |
parent | Don't fail to create an IRC nick if nick randomization is disabled in the IRC... (diff) | |
download | opensim-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/WebUtil.cs | 41 |
1 files changed, 33 insertions, 8 deletions
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; |