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 datacpu-performance
parent
135e10ba09
commit
47b6e78790
|
@ -121,12 +121,14 @@ namespace OpenSim.Framework.Servers
|
||||||
+ " level >= 2 then long warnings are logged when receiving bad input data.\n"
|
+ " level >= 2 then long warnings are logged when receiving bad input data.\n"
|
||||||
+ " level >= 3 then short notices about all incoming non-poll HTTP requests are logged.\n"
|
+ " level >= 3 then short notices about all incoming non-poll HTTP requests are logged.\n"
|
||||||
+ " level >= 4 then the time taken to fulfill the request is logged.\n"
|
+ " level >= 4 then the time taken to fulfill the request is logged.\n"
|
||||||
+ " level >= 5 then a sample from the beginning of the incoming data is logged.\n"
|
+ " level >= 5 then a sample from the beginning of the data is logged.\n"
|
||||||
+ " level >= 6 then the entire incoming data is logged.\n"
|
+ " level >= 6 then the entire data is logged.\n"
|
||||||
+ " no level is specified then the current level is returned.\n\n"
|
+ " no level is specified then the current level is returned.\n\n"
|
||||||
+ "If out or all and\n"
|
+ "If out or all and\n"
|
||||||
+ " level >= 3 then short notices about all outgoing requests going through WebUtil are logged.\n"
|
+ " level >= 3 then short notices about all outgoing requests going through WebUtil are logged.\n"
|
||||||
+ " level >= 4 then the time taken to fulfill the request is logged.\n",
|
+ " level >= 4 then the time taken to fulfill the request is logged.\n"
|
||||||
|
+ " level >= 5 then a sample from the beginning of the data is logged.\n"
|
||||||
|
+ " level >= 6 then the entire data is logged.\n",
|
||||||
HandleDebugHttpCommand);
|
HandleDebugHttpCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,39 @@ namespace OpenSim.Framework
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void LogOutgoingDetail(Stream outputStream)
|
||||||
|
{
|
||||||
|
using (StreamReader reader = new StreamReader(Util.Copy(outputStream), Encoding.UTF8))
|
||||||
|
{
|
||||||
|
string output;
|
||||||
|
|
||||||
|
if (DebugLevel == 5)
|
||||||
|
{
|
||||||
|
const int sampleLength = 80;
|
||||||
|
char[] sampleChars = new char[sampleLength];
|
||||||
|
reader.Read(sampleChars, 0, sampleLength);
|
||||||
|
output = new string(sampleChars);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
output = reader.ReadToEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
LogOutgoingDetail(output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LogOutgoingDetail(string output)
|
||||||
|
{
|
||||||
|
if (DebugLevel == 5)
|
||||||
|
{
|
||||||
|
output = output.Substring(0, 80);
|
||||||
|
output = output + "...";
|
||||||
|
}
|
||||||
|
|
||||||
|
m_log.DebugFormat("[WEB UTIL]: {0}", output.Replace("\n", @"\n"));
|
||||||
|
}
|
||||||
|
|
||||||
private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed)
|
private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed)
|
||||||
{
|
{
|
||||||
int reqnum = RequestNumber++;
|
int reqnum = RequestNumber++;
|
||||||
|
@ -179,6 +212,10 @@ namespace OpenSim.Framework
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
strBuffer = OSDParser.SerializeJsonString(data);
|
strBuffer = OSDParser.SerializeJsonString(data);
|
||||||
|
|
||||||
|
if (DebugLevel >= 5)
|
||||||
|
LogOutgoingDetail(strBuffer);
|
||||||
|
|
||||||
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer);
|
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer);
|
||||||
|
|
||||||
if (compressed)
|
if (compressed)
|
||||||
|
@ -357,6 +394,10 @@ namespace OpenSim.Framework
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
queryString = BuildQueryString(data);
|
queryString = BuildQueryString(data);
|
||||||
|
|
||||||
|
if (DebugLevel >= 5)
|
||||||
|
LogOutgoingDetail(queryString);
|
||||||
|
|
||||||
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(queryString);
|
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(queryString);
|
||||||
|
|
||||||
request.ContentLength = buffer.Length;
|
request.ContentLength = buffer.Length;
|
||||||
|
@ -767,6 +808,9 @@ namespace OpenSim.Framework
|
||||||
int length = (int)buffer.Length;
|
int length = (int)buffer.Length;
|
||||||
request.ContentLength = length;
|
request.ContentLength = length;
|
||||||
|
|
||||||
|
if (WebUtil.DebugLevel >= 5)
|
||||||
|
WebUtil.LogOutgoingDetail(buffer);
|
||||||
|
|
||||||
request.BeginGetRequestStream(delegate(IAsyncResult res)
|
request.BeginGetRequestStream(delegate(IAsyncResult res)
|
||||||
{
|
{
|
||||||
Stream requestStream = request.EndGetRequestStream(res);
|
Stream requestStream = request.EndGetRequestStream(res);
|
||||||
|
@ -954,6 +998,9 @@ namespace OpenSim.Framework
|
||||||
length = (int)obj.Length;
|
length = (int)obj.Length;
|
||||||
request.ContentLength = length;
|
request.ContentLength = length;
|
||||||
|
|
||||||
|
if (WebUtil.DebugLevel >= 5)
|
||||||
|
WebUtil.LogOutgoingDetail(buffer);
|
||||||
|
|
||||||
Stream requestStream = null;
|
Stream requestStream = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1096,6 +1143,9 @@ namespace OpenSim.Framework
|
||||||
int length = (int)buffer.Length;
|
int length = (int)buffer.Length;
|
||||||
request.ContentLength = length;
|
request.ContentLength = length;
|
||||||
|
|
||||||
|
if (WebUtil.DebugLevel >= 5)
|
||||||
|
WebUtil.LogOutgoingDetail(buffer);
|
||||||
|
|
||||||
Stream requestStream = null;
|
Stream requestStream = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue