在IntelliJ IDEA中自动完成log.info吗? [英] Automatic `log.info` completion in IntelliJ IDEA?

查看:103
本文介绍了在IntelliJ IDEA中自动完成log.info吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Java,并且记录如下内容:

  log.info("createArticle userId = {} articleId = {} title = {} content = {}",userId,articleId,标题,内容); 

如您所见,当将此行输入到我的IDE中时,我必须手动记下那些字符,如" userId = {}" .理想情况下,我希望我可以简单地键入 userId ,并且Intellij IDEA会自动帮助我填写"userId = {}" (格式字符串)和,userId (在参数列表中).

问题:如何在IntelliJ IDEA中做到这一点?或者,还有其他方法可以更快更快地键入此类日志记录行吗?

谢谢您的建议!

解决方案

可以使用

请参阅视频

I am using Java and I log things like:

log.info("createArticle userId={} articleId={} title={} content={}", userId, articleId, title, content);

As you can see, when inputting this line into my IDE, I have to manually write down those characters like "userId={} ". Ideally, I hope I can simply type the userId, and Intellij IDEA will automatically help me fill out both "userId={} " (in the format string) and , userId (in the arguments list).

Question: How can I do that in IntelliJ IDEA? Or, is there any other ways to type such logging lines faster?

Thanks for any suggestions!

解决方案

It is possible to implement it with Live Templates and groovyScript for one of the variables: take the second segment, split it by comma, concat in something like part=${part}:

groovyScript("_1.split(',').collect { it.trim() + '={}' }.join(' ')", B)

See video

这篇关于在IntelliJ IDEA中自动完成log.info吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆