1:打印入参日志的配置
log.info("$methodName$ 方法入参: $argsLog$",$argsJson$);
methodName:methodName()
argsLog:groovyScript( ?"def result=''; ?def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList(); ?for(i = 0; i < params.size(); i++) { ?result+= params[i] + ((i < params.size() - 1) ? ':[{}], ' : ':[{}]') }; ?return result" , methodParameters())
argsJson:groovyScript(" def result=''; ? def types = 'String,int,Integer,long,Long,float,Float,double,Double,byte,Byte,short,Short,char,Char,boolean,Boolean'; ? def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]','').split(',').toList(); ? def paramTypes=\"${_2}\".replaceAll('[\\\\[|\\\\]|\\\\s]','').split(',').toList(); ? for(i = 0; i < params.size(); i++) { ? ?if(types.contains(paramTypes[i].replace('java.lang.',''))){ ?result+=params[i] + ((i < params.size() - 1) ? ', ' : ''); ? ?}else{ ?result+='JSONObject.toJSONString(' + params[i] + ((i < params.size() - 1) ? '), ' : ')'); ? ?} ? }; ? return result; " , methodParameters(), methodParameterTypes())
2、打印返回结果日志的配置
log.info("$METHOD_NAME$() returned: {}" , $result$);
methodName:methodName()
result:variableOfType(Type)