Skip to content

Instantly share code, notes, and snippets.

@ichengzi
Last active July 18, 2023 01:30
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ichengzi/6933bd03d1c25f8935d85859a5e6425a to your computer and use it in GitHub Desktop.
idea 日志 live template. 快速打印日志,入参,返回,异常

来源: 【我把老婆(冰冰)放到了Idea 里!这是一个正经视频,后面还讲了代码快速补全,live template 打日志。】 【精准空降到 05:46】 https://www.bilibili.com/video/BV1uR4y1p7Lh/?share_source=copy_web&vd_source=af63ea840971731c498a30c3de502821&t=346

loge
log.error($content$,$params$);
content 参数:
groovyScript("def params = _2.collect {'【'+it+' = {}】'}.join(', '); return '\"[[title='+_1+']] ' + _1 + '() called with exception => ' + (params.empty  ? '' : params) + '\"'", methodName(), methodParameters())
params参数:
groovyScript("def params = _1.collect {it}.join(', '); return   (params.empty  ? '' : params) + ',e' ",  methodParameters())


logm
log.info($content$,$params$);
content参数:
groovyScript("def params = _2.collect {'【'+it+' = {}】'}.join(', '); return '\"[[title='+_1+']] ' + _1 + '() called with parameters => ' + (params.empty  ? '' : params) + '\"'", methodName(), methodParameters())
params参数:
groovyScript("def params = _1.collect {it}.join(', '); return   (params.empty  ? '' : params) ",  methodParameters())


logr
log.info("[[title=$METHOD_NAME$]] $METHOD_NAME$() returned: " +  $result$);
METHOD_NAME参数: 
methodName()
result参数:
variableOfType(methodReturnType())
@ichengzi
Copy link
Author

测试效果

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment