Created
September 4, 2017 18:53
-
-
Save dumazy/fe0ba890ec2b2e4093ba27896a26415d to your computer and use it in GitHub Desktop.
Android Studio Live Templates for Log statements in Kotlin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<templateSet group="AndroidLogKotlin"> | |
<template name="logd" value="android.util.Log.d("$CLASS_NAME$", "$METHOD_NAME$ (line $LINE$): $MESSAGE$")$END$" description="Log.d statement" toReformat="false" toShortenFQNames="true"> | |
<variable name="CLASS_NAME" expression="groovyScript("if(_1.length() > 23) { return _1.substring(0, 23)} else { return _1}", kotlinClassName())" defaultValue="" alwaysStopAt="true" /> | |
<variable name="METHOD_NAME" expression="kotlinFunctionName()" defaultValue="" alwaysStopAt="false" /> | |
<variable name="LINE" expression="lineNumber()" defaultValue="" alwaysStopAt="false" /> | |
<variable name="MESSAGE" expression="" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="KOTLIN_STATEMENT" value="true" /> | |
</context> | |
</template> | |
<template name="logi" value="android.util.Log.i("$CLASS_NAME$", "$METHOD_NAME$ (line $LINE$): $MESSAGE$")$END$" description="Log.i statement" toReformat="false" toShortenFQNames="true"> | |
<variable name="CLASS_NAME" expression="groovyScript("if(_1.length() > 23) { return _1.substring(0, 23)} else { return _1}", kotlinClassName())" defaultValue="" alwaysStopAt="true" /> | |
<variable name="METHOD_NAME" expression="kotlinFunctionName()" defaultValue="" alwaysStopAt="false" /> | |
<variable name="LINE" expression="lineNumber()" defaultValue="" alwaysStopAt="false" /> | |
<variable name="MESSAGE" expression="" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="KOTLIN_STATEMENT" value="true" /> | |
</context> | |
</template> | |
<template name="loge" value="android.util.Log.e("$CLASS_NAME$", "$METHOD_NAME$ (line $LINE$): $MESSAGE$", $exception$)$END$" description="Log.e statement" toReformat="false" toShortenFQNames="true"> | |
<variable name="CLASS_NAME" expression="groovyScript("if(_1.length() > 23) { return _1.substring(0, 23)} else { return _1}", kotlinClassName())" defaultValue="" alwaysStopAt="true" /> | |
<variable name="METHOD_NAME" expression="kotlinFunctionName()" defaultValue="" alwaysStopAt="false" /> | |
<variable name="LINE" expression="lineNumber()" defaultValue="" alwaysStopAt="false" /> | |
<variable name="MESSAGE" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="exception" expression="" defaultValue="e" alwaysStopAt="false" /> | |
<context> | |
<option name="KOTLIN_STATEMENT" value="true" /> | |
</context> | |
</template> | |
<template name="logw" value="android.util.Log.e("$CLASS_NAME$", "$METHOD_NAME$ (line $LINE$): $MESSAGE$")$END$" description="Log.w statement" toReformat="false" toShortenFQNames="true"> | |
<variable name="CLASS_NAME" expression="groovyScript("if(_1.length() > 23) { return _1.substring(0, 23)} else { return _1}", kotlinClassName())" defaultValue="" alwaysStopAt="true" /> | |
<variable name="METHOD_NAME" expression="kotlinFunctionName()" defaultValue="" alwaysStopAt="false" /> | |
<variable name="LINE" expression="lineNumber()" defaultValue="" alwaysStopAt="false" /> | |
<variable name="MESSAGE" expression="" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="KOTLIN_STATEMENT" value="true" /> | |
</context> | |
</template> | |
</templateSet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is better for me, if this is ported to java.