Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
Add request and response infomation in the debug log
Browse files Browse the repository at this point in the history
---

Fixes #64

*Motivation*

Currently, kop protocol handler only prints header at debug
statements. We also need request and response.

*Modifications*

- Add more request and response info
  • Loading branch information
zymap committed Jan 14, 2020
1 parent b115d3b commit 9813bf4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/java/io/streamnative/kop/KafkaCommandDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception

try (KafkaHeaderAndRequest kafkaHeaderAndRequest = byteBufToRequest(buffer, remoteAddress)){
if (log.isDebugEnabled()) {
log.debug("[{}] Received kafka cmd {}",
log.debug("[{}] Received kafka cmd {}, the request content is: {}",
ctx.channel() != null ? ctx.channel().remoteAddress() : "Null channel",
kafkaHeaderAndRequest.getHeader());
kafkaHeaderAndRequest.getHeader(), kafkaHeaderAndRequest);
}

switch (kafkaHeaderAndRequest.getHeader().apiKey()) {
Expand Down Expand Up @@ -232,8 +232,11 @@ protected void writeAndFlushResponseToClient(Channel channel) {
try {
ResponseAndRequest pair = response.join();
if (log.isDebugEnabled()) {
log.debug("Write kafka cmd response back to client. request: {}",
pair.getRequest().getHeader());
log.debug("Write kafka cmd response back to client. \n" +
"\trequest content: {} \n" +
"\tresponse content: {}",
pair.getRequest().toString(),
pair.getResponse().toString(pair.getRequest().getRequest().version()));
}

ByteBuf result = responseToByteBuf(pair.getResponse(), pair.getRequest());
Expand Down

0 comments on commit 9813bf4

Please sign in to comment.