package com.wmz7year.synyed.command.filter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.wmz7year.synyed.entity.RedisCommand;
import com.wmz7year.synyed.entity.RedisServer;
import com.wmz7year.synyed.exception.RedisCommandRejectedException;

/**
 * 对同步命令进行日志记录的拦截器
 * 
 * @Title: RedisCommandLogInterceptor.java
 * @Package com.wmz7year.synyed.command.filter
 * @author jiangwei (ydswcy513@gmail.com)
 * @date 2015年12月22日 下午2:42:49
 * @version V1.0
 */
@Component
public class RedisCommandLogInterceptor implements RedisCommandInterceptor {
	private static final Logger logger = LoggerFactory.getLogger(RedisCommandLogInterceptor.class);

	/*
	 * @see com.wmz7year.synyed.command.filter.RedisCommandInterceptor#
	 * beforeSendCommand(com.wmz7year.synyed.entity.RedisCommand,
	 * com.wmz7year.synyed.entity.RedisServer,
	 * com.wmz7year.synyed.entity.RedisServer)
	 */
	@Override
	public void beforeSendCommand(RedisCommand command, RedisServer srcServer, RedisServer descServer)
			throws RedisCommandRejectedException {
		logger.info("beforeSendCommand:" + command);
	}

	/*
	 * @see com.wmz7year.synyed.command.filter.RedisCommandInterceptor#
	 * afterSendCommand(com.wmz7year.synyed.entity.RedisCommand, boolean,
	 * com.wmz7year.synyed.entity.RedisServer,
	 * com.wmz7year.synyed.entity.RedisServer)
	 */
	@Override
	public void afterSendCommand(RedisCommand command, boolean result, RedisServer srcServer, RedisServer descServer)
			throws RedisCommandRejectedException {
		logger.info("afterSendCommand:" + command);
	}

	/*
	 * @see com.wmz7year.synyed.command.filter.RedisCommandInterceptor#getName()
	 */
	@Override
	public String getName() {
		return "command logger filter";
	}

}

@@ -1103,33 +1103,22 @@
 r.info(%22
-beforeSendCommand
+%E5%87%86%E5%A4%87%E5%90%8C%E6%AD%A5%E5%91%BD%E4%BB%A4
 :%22 + com
@@ -1552,36 +1552,42 @@
 fo(%22
-afterSendCommand:%22 + command
+%E5%90%8C%E6%AD%A5%E5%91%BD%E4%BB%A4:%22 + command + %22 %E7%BB%93%E6%9E%9C%EF%BC%9A%22 + result
 );%0A%09

修改日志拦截器 日志输出内容