improved debug logging

This commit is contained in:
Greg Wilkins 2014-09-21 15:03:44 +10:00
parent 580c87bcc6
commit fc4bfc8a66
4 changed files with 40 additions and 9 deletions

View File

@ -55,10 +55,20 @@ public class HTTP2Connection extends AbstractConnection
@Override
public void onOpen()
{
if (LOG.isDebugEnabled())
LOG.debug("HTTP2 Open {} ", this);
super.onOpen();
fillInterested();
}
@Override
public void onClose()
{
if (LOG.isDebugEnabled())
LOG.debug("HTTP2 Close {} ", this);
super.onClose();
}
@Override
public void onFillable()
{
@ -75,8 +85,6 @@ public class HTTP2Connection extends AbstractConnection
while (true)
{
int filled = fill(endPoint, buffer);
if (LOG.isDebugEnabled()) // Avoid boxing of variable 'filled'
LOG.debug("Read {} bytes", filled);
if (filled == 0)
{
return 0;

View File

@ -24,6 +24,7 @@ import java.nio.ByteBuffer;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpGenerator;
import org.eclipse.jetty.http.HttpGenerator.ResponseInfo;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpHeaderValue;
import org.eclipse.jetty.http.MetaData;
@ -40,6 +41,8 @@ import org.eclipse.jetty.server.HttpInput;
import org.eclipse.jetty.server.HttpTransport;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -83,8 +86,8 @@ public class HttpChannelOverHTTP2 extends HttpChannel
if (LOG.isDebugEnabled())
{
LOG.debug("HTTP2 Request #{}:{}{} {} {}{}{}",
stream.getId(), System.lineSeparator(), request.getMethod(), request.getURI(), request.getVersion(),
LOG.debug("HTTP2 Request #{}/{}:{}{} {} {}{}{}",
stream.getId(), Integer.toHexString(stream.getSession().hashCode()), System.lineSeparator(), request.getMethod(), request.getURI(), request.getVersion(),
System.lineSeparator(), fields);
}
@ -98,13 +101,24 @@ public class HttpChannelOverHTTP2 extends HttpChannel
if (LOG.isDebugEnabled())
{
LOG.debug("HTTP2 Push Request #{}:{}{} {} {}{}{}",
stream.getId(), System.lineSeparator(), request.getMethod(), request.getURI(), request.getVersion(),
LOG.debug("HTTP2 PUSH Request #{}/{}:{}{} {} {}{}{}",
stream.getId(),Integer.toHexString(stream.getSession().hashCode()), System.lineSeparator(), request.getMethod(), request.getURI(), request.getVersion(),
System.lineSeparator(), request.getFields());
}
execute(this);
}
@Override
protected void commit(ResponseInfo info)
{
if (LOG.isDebugEnabled())
{
LOG.debug("HTTP2 Commit Response #{}/{}:{}{} {} {}{}{}",
stream.getId(),Integer.toHexString(stream.getSession().hashCode()), System.lineSeparator(), info.getHttpVersion(), info.getStatus(), info.getReason(),
System.lineSeparator(), info.getHttpFields());
}
}
public void requestContent(DataFrame frame, final Callback callback)
{
@ -116,7 +130,7 @@ public class HttpChannelOverHTTP2 extends HttpChannel
copy.put(original).flip();
if (LOG.isDebugEnabled())
LOG.debug("HTTP2 Request #{}: {} bytes of content", stream.getId(), copy.remaining());
LOG.debug("HTTP2 Request #{}/{}: {} bytes of content", stream.getId(),Integer.toHexString(stream.getSession().hashCode()), copy.remaining());
onContent(new HttpInput.Content(copy)
{

View File

@ -1,3 +1,5 @@
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
org.eclipse.jetty.http2.LEVEL=INFO
#org.eclipse.jetty.http2.HTTP2Connection.LEVEL=DEBUG
#org.eclipse.jetty.http2.server.HttpChannelOverHTTP2.LEVEL=DEBUG
org.eclipse.jetty.servlets.PushCacheFilter.LEVEL=DEBUG

View File

@ -544,7 +544,8 @@ public class HttpChannel implements Runnable
// We need an info to commit
if (info==null)
info = _response.newResponseInfo();
commit(info);
// wrap callback to process 100 responses
final int status=info.getStatus();
final Callback committed = (status<200&&status>=100)?new Commit100Callback(callback):new CommitCallback(callback);
@ -580,6 +581,12 @@ public class HttpChannel implements Runnable
throw failure;
}
}
protected void commit (ResponseInfo info)
{
if (LOG.isDebugEnabled())
LOG.debug("Commit {} to {}",info,this);
}
public boolean isCommitted()
{