Skip to content

Instantly share code, notes, and snippets.

@timtsj
Created March 19, 2020 06:05
Show Gist options
  • Select an option

  • Save timtsj/aa814c1b7e2d93133709acf82d4ab251 to your computer and use it in GitHub Desktop.

Select an option

Save timtsj/aa814c1b7e2d93133709acf82d4ab251 to your computer and use it in GitHub Desktop.
LogTimberKotlin.xml template
<templateSet group="LogTimberKotlin">
<template name="timm" value="timber.log.Timber.d($FORMAT$)" description="Log method name and its arguments" toReformat="true" toShortenFQNames="true">
<variable name="NAME" expression="groovyScript(&quot;_1.take(Math.min(23, _1.length()));&quot;, kotlinClassName())" defaultValue="" alwaysStopAt="false" />
<variable name="FORMAT" expression="groovyScript(&quot;def params = _2.collect {it + ' = [$' + it + ']'}.join(', '); return '\&quot;' + _1 + '() called' + (params.empty ? '' : ' with: ' + params) + '\&quot;'&quot;, kotlinFunctionName(), functionParameters())" defaultValue="" alwaysStopAt="false" />
<context>
<option name="KOTLIN_STATEMENT" value="true" />
</context>
</template>
<template name="timd" value="timber.log.Timber.d(&quot;$METHOD_NAME$: $content$&quot;)" description="Timber.d(String)" toReformat="true" toShortenFQNames="true">
<variable name="NAME" expression="groovyScript(&quot;_1.take(Math.min(23, _1.length()));&quot;, kotlinClassName())" defaultValue="" alwaysStopAt="false" />
<variable name="METHOD_NAME" expression="kotlinFunctionName()" defaultValue="" alwaysStopAt="false" />
<variable name="content" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="KOTLIN_STATEMENT" value="true" />
</context>
</template>
<template name="time" value="timber.log.Timber.e(&quot;$METHOD_NAME$: $content$&quot;, $exception$)" description="Timber.e(Exception, String)" toReformat="true" toShortenFQNames="true">
<variable name="NAME" expression="groovyScript(&quot;_1.take(Math.min(23, _1.length()));&quot;, kotlinClassName())" defaultValue="" alwaysStopAt="false" />
<variable name="METHOD_NAME" expression="kotlinFunctionName()" defaultValue="" alwaysStopAt="false" />
<variable name="content" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="exception" expression="" defaultValue="e" alwaysStopAt="true" />
<context>
<option name="KOTLIN_STATEMENT" value="true" />
</context>
</template>
<template name="timi" value="timber.log.Timber.i(&quot;$METHOD_NAME$: $content$&quot;)" description="Timber.i(String)" toReformat="true" toShortenFQNames="true">
<variable name="NAME" expression="groovyScript(&quot;_1.take(Math.min(23, _1.length()));&quot;, kotlinClassName())" defaultValue="" alwaysStopAt="false" />
<variable name="METHOD_NAME" expression="kotlinFunctionName()" defaultValue="" alwaysStopAt="false" />
<variable name="content" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="KOTLIN_STATEMENT" value="true" />
</context>
</template>
<template name="timw" value="timber.log.Timber.w(&quot;$METHOD_NAME$: $content$&quot;)" description="Timber.w(Exception, String)" toReformat="true" toShortenFQNames="true">
<variable name="NAME" expression="groovyScript(&quot;_1.take(Math.min(23, _1.length()));&quot;, kotlinClassName())" defaultValue="" alwaysStopAt="false" />
<variable name="METHOD_NAME" expression="kotlinFunctionName()" defaultValue="" alwaysStopAt="false" />
<variable name="content" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="KOTLIN_STATEMENT" value="true" />
</context>
</template>
<template name="timwtf" value="timber.log.Timber.wtf(&quot;$METHOD_NAME$: $content$&quot;)" description="Timber.wtf(Exception, String)" toReformat="true" toShortenFQNames="true">
<variable name="NAME" expression="groovyScript(&quot;_1.take(Math.min(23, _1.length()));&quot;, kotlinClassName())" defaultValue="" alwaysStopAt="false" />
<variable name="METHOD_NAME" expression="kotlinFunctionName()" defaultValue="" alwaysStopAt="false" />
<variable name="content" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="KOTLIN_STATEMENT" value="true" />
</context>
</template>
<template name="timt" value="Timber.tag(&quot;$tag$&quot;)" description="a logtag for the next logging call" toReformat="true" toShortenFQNames="true">
<variable name="tag" 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