300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > AOP切面日志

AOP切面日志

时间:2021-03-21 22:57:02

相关推荐

AOP切面日志

package com.vivo.finance.vivopay.core.aop;

/**

该切面主要是打印日志,需要注意一下几点1.打印的方法为com.vivo.finance.member.core.facade 目录下添加@com.vivo.finance.mon.NeedLogInAndOut 的方法才能进入打印2.提供过滤加密打印,需要在加密的字段添加上@SecurityParam,这样会加密打印@Author : JimmyZ on /8/21 23:33

**/

import com.mon.exception.FinanceBizException;

import com.mon.exception.FinanceRuntimeException;

import com.mon.utils.JsonUtils;

import com.vivo.finance.vivopay.core.exception.ExceptionConstants;

import com.vivo.finance.vivopay.core.exception.NfcCardsBizException;

import com.vivo.finance.vivopay.core.exception.VivoPayInterfaceBizException;

import com.vivo.finance.vivopay.core.exception.VivoPayInterfaceException;

import org.aspectj.lang.ProceedingJoinPoint;

import org.aspectj.lang.annotation.Around;

import org.aspectj.lang.annotation.Aspect;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

import org.ponent;

@Component //加入到IoC容器

@Aspect //指定当前类为切面类

public class LogAop {

private Logger logger = LoggerFactory.getLogger(getClass());@Around("execution(* com.vivo.finance.vivopay.core.biz.*.*(..))")public Object pointCut(ProceedingJoinPoint pjp) {Object retVal = null;String methodName = pjp.getSignature().getName();String className = pjp.getTarget().getClass().getName();Object[] args = pjp.getArgs();try {

// String argsSerialize = JsonUtils.serialize(args == null ? “” : args);

// logger.info("{}#{} req params is {}", className, methodName, argsSerialize);

retVal = pjp.proceed(args);

// String retSerialize = JsonUtils.serialize(retVal == null ? “” : retVal);

// logger.info("{}#{} rsp result is 1 {}", className, methodName, retSerialize);

} catch (VivoPayInterfaceBizException e) {

logger.warn("{}#{} interface biz error, code is {}, msg is {}", className, methodName, e.getDefineCode(), e.getMessage());

throw VivoPayInterfaceException.newException(e,e.getMessage());

}catch (FinanceBizException e) {

logger.error("{}#{} biz error, code is {}, msg is {}", className, methodName, e.getDefineCode(), e.getMessage(), e);

if(VivoPayInterfaceException.class.isInstance(e)){

throw VivoPayInterfaceException.newException((VivoPayInterfaceException)e,e.getMessage());

}

throw FinanceBizException.newException(e);

} catch (FinanceRuntimeException e) {

logger.error("{}#{} runtime error, msg is {}", className, methodName,e.getMessage(), e);

throw e;

} catch (Throwable e) {

logger.error("{}#{} error, msg is {}", className, methodName,e.getMessage(), e);

throw NfcCardsBizException.newException(ExceptionConstants.SERVER_ERROR, e.getMessage());

}

return retVal;

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。