Idea live template

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)

相关推荐
_小马快跑_16 小时前
Java 的 8 大基本数据类型:为何是不可或缺的设计?
java
阿尔的代码屋17 小时前
[大模型实战 07] 基于 LlamaIndex ReAct 框架手搓全自动博客监控 Agent
人工智能·python
Re_zero18 小时前
线上日志被清空?这段仅10行的 IO 代码里竟然藏着3个毒瘤
java·后端
洋洋技术笔记18 小时前
Spring Boot条件注解详解
java·spring boot
AI探索者1 天前
LangGraph StateGraph 实战:状态机聊天机器人构建指南
python
AI探索者1 天前
LangGraph 入门:构建带记忆功能的天气查询 Agent
python
程序员清风2 天前
程序员兼职必看:靠谱软件外包平台挑选指南与避坑清单!
java·后端·面试
FishCoderh2 天前
Python自动化办公实战:批量重命名文件,告别手动操作
python
躺平大鹅2 天前
Python函数入门详解(定义+调用+参数)
python
皮皮林5512 天前
利用闲置 Mac 从零部署 OpenClaw 教程 !
java