aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-06-12 21:34:20 +0100
committerJustin Clark-Casey (justincc)2013-06-12 21:34:20 +0100
commit47b6e78790be5a4b7d8a0f4c860f1e2f6f87b137 (patch)
tree8c0f7b31f2b3b6b086cdd65b367654798bd3e6fc /OpenSim
parentUncomment Mic's code and split to create new regression TestAddTemporaryAsset... (diff)
downloadopensim-SC_OLD-47b6e78790be5a4b7d8a0f4c860f1e2f6f87b137.zip
opensim-SC_OLD-47b6e78790be5a4b7d8a0f4c860f1e2f6f87b137.tar.gz
opensim-SC_OLD-47b6e78790be5a4b7d8a0f4c860f1e2f6f87b137.tar.bz2
opensim-SC_OLD-47b6e78790be5a4b7d8a0f4c860f1e2f6f87b137.tar.xz
Implement logging of first 80 characters (debug level 5) or full body data (debug level 6) on outgoing requests, depending on debug level
This is set via "debug http out <level>" This matches the existing debug level behaviours for logging incoming http data
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Servers/MainServer.cs8
-rw-r--r--OpenSim/Framework/WebUtil.cs54
2 files changed, 57 insertions, 5 deletions
diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs
index cfd34bb..d189580 100644
--- a/OpenSim/Framework/Servers/MainServer.cs
+++ b/OpenSim/Framework/Servers/MainServer.cs
@@ -121,12 +121,14 @@ namespace OpenSim.Framework.Servers
121 + " level >= 2 then long 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" 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" 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" 124 + " level >= 5 then a sample from the beginning of the data is logged.\n"
125 + " level >= 6 then the entire incoming data is logged.\n" 125 + " level >= 6 then the entire data is logged.\n"
126 + " no level is specified then the current level is returned.\n\n" 126 + " no level is specified then the current level is returned.\n\n"
127 + "If out or all and\n" 127 + "If out or all and\n"
128 + " level >= 3 then short notices about all outgoing requests going through WebUtil are logged.\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", 129 + " level >= 4 then the time taken to fulfill the request is logged.\n"
130 + " level >= 5 then a sample from the beginning of the data is logged.\n"
131 + " level >= 6 then the entire data is logged.\n",
130 HandleDebugHttpCommand); 132 HandleDebugHttpCommand);
131 } 133 }
132 134
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs
index 701fbb0..4599f62 100644
--- a/OpenSim/Framework/WebUtil.cs
+++ b/OpenSim/Framework/WebUtil.cs
@@ -151,6 +151,39 @@ namespace OpenSim.Framework
151 } 151 }
152 } 152 }
153 153
154 public static void LogOutgoingDetail(Stream outputStream)
155 {
156 using (StreamReader reader = new StreamReader(Util.Copy(outputStream), Encoding.UTF8))
157 {
158 string output;
159
160 if (DebugLevel == 5)
161 {
162 const int sampleLength = 80;
163 char[] sampleChars = new char[sampleLength];
164 reader.Read(sampleChars, 0, sampleLength);
165 output = new string(sampleChars);
166 }
167 else
168 {
169 output = reader.ReadToEnd();
170 }
171
172 LogOutgoingDetail(output);
173 }
174 }
175
176 public static void LogOutgoingDetail(string output)
177 {
178 if (DebugLevel == 5)
179 {
180 output = output.Substring(0, 80);
181 output = output + "...";
182 }
183
184 m_log.DebugFormat("[WEB UTIL]: {0}", output.Replace("\n", @"\n"));
185 }
186
154 private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed) 187 private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed)
155 { 188 {
156 int reqnum = RequestNumber++; 189 int reqnum = RequestNumber++;
@@ -178,7 +211,11 @@ namespace OpenSim.Framework
178 // If there is some input, write it into the request 211 // If there is some input, write it into the request
179 if (data != null) 212 if (data != null)
180 { 213 {
181 strBuffer = OSDParser.SerializeJsonString(data); 214 strBuffer = OSDParser.SerializeJsonString(data);
215
216 if (DebugLevel >= 5)
217 LogOutgoingDetail(strBuffer);
218
182 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer); 219 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer);
183 220
184 if (compressed) 221 if (compressed)
@@ -357,6 +394,10 @@ namespace OpenSim.Framework
357 if (data != null) 394 if (data != null)
358 { 395 {
359 queryString = BuildQueryString(data); 396 queryString = BuildQueryString(data);
397
398 if (DebugLevel >= 5)
399 LogOutgoingDetail(queryString);
400
360 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(queryString); 401 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(queryString);
361 402
362 request.ContentLength = buffer.Length; 403 request.ContentLength = buffer.Length;
@@ -767,6 +808,9 @@ namespace OpenSim.Framework
767 int length = (int)buffer.Length; 808 int length = (int)buffer.Length;
768 request.ContentLength = length; 809 request.ContentLength = length;
769 810
811 if (WebUtil.DebugLevel >= 5)
812 WebUtil.LogOutgoingDetail(buffer);
813
770 request.BeginGetRequestStream(delegate(IAsyncResult res) 814 request.BeginGetRequestStream(delegate(IAsyncResult res)
771 { 815 {
772 Stream requestStream = request.EndGetRequestStream(res); 816 Stream requestStream = request.EndGetRequestStream(res);
@@ -954,6 +998,9 @@ namespace OpenSim.Framework
954 length = (int)obj.Length; 998 length = (int)obj.Length;
955 request.ContentLength = length; 999 request.ContentLength = length;
956 1000
1001 if (WebUtil.DebugLevel >= 5)
1002 WebUtil.LogOutgoingDetail(buffer);
1003
957 Stream requestStream = null; 1004 Stream requestStream = null;
958 try 1005 try
959 { 1006 {
@@ -1096,6 +1143,9 @@ namespace OpenSim.Framework
1096 int length = (int)buffer.Length; 1143 int length = (int)buffer.Length;
1097 request.ContentLength = length; 1144 request.ContentLength = length;
1098 1145
1146 if (WebUtil.DebugLevel >= 5)
1147 WebUtil.LogOutgoingDetail(buffer);
1148
1099 Stream requestStream = null; 1149 Stream requestStream = null;
1100 try 1150 try
1101 { 1151 {
@@ -1198,4 +1248,4 @@ namespace OpenSim.Framework
1198 return deserial; 1248 return deserial;
1199 } 1249 }
1200 } 1250 }
1201} 1251} \ No newline at end of file