Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add command logging #3885

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/main/java/redis/clients/jedis/Protocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
import redis.clients.jedis.util.RedisOutputStream;
import redis.clients.jedis.util.SafeEncoder;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class Protocol {
protected static Logger logger = LoggerFactory.getLogger(Protocol.class.getName());

public static final String DEFAULT_HOST = "127.0.0.1";
public static final int DEFAULT_PORT = 6379;
Expand Down Expand Up @@ -63,6 +67,15 @@ private Protocol() {
}

public static void sendCommand(final RedisOutputStream os, CommandArguments args) {
if(logger.isDebugEnabled()) {
StringBuilder logMessage = new StringBuilder();
for (Rawable arg : args) {
logMessage.append(new String(arg.getRaw()));
logMessage.append(" ");
}
logger.debug(logMessage.toString());
}

try {
os.write(ASTERISK_BYTE);
os.writeIntCrLf(args.size());
Expand Down