Skip to content

Android Studio Live Templates for Logging in Kotlin (Timber Log)

License

Notifications You must be signed in to change notification settings

jdsingh/android-studio-timber-log-templates-for-kotlin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

Android Studio Timber Log Templates for Kotlin

Android Studio provides 'Live Templates' for inserting recurring code snippets like loops and log statements. For example, hitting TAB when entering logd will produce

    Log.d("divide: foo");

Not all templates are available for Kotlin, yet. To spare you the time of creating them, this repo provides the Kotlin version of the timber log templates.

Download

OR

  • Download templates/AndroidLogKotlin.xml and move it into Android Studio's templates directory (on Windows: C:\Users\John\.AndroidStudio3.1\config\templates)

The templates will be available after restarting Android Studio.

Usage

logd - Timber.d(String)

    Timber.d("divide: foo")

loge - Timber.e(Exception, String)

    Timber.e(e, "divide: foo")

logi - Timber.i(String)

    Timber.i("divide: foo")

logm - Log method name and its arguments

    Timber.d("divide() called with: a = [$a], b = [$b]")

logr - Log result of this method

    Timber.d("divide() returned: $result")

logw - Log.w(Exception, String)

    Timber.w(e, "divide: foo")

wtf - Log.wtf(Exception, String)

    Timber.wtf(e, "divide: foo")

Note: Any changes you've made to the Java log templates will get lost as the 'AndroidLog.xml' file is overwritten. You can prevent this by merging the XML files manually.

The templates will be available after restarting Android Studio.

Modify Templates

One can edit these templates and add new ones in Android Studio under 'Settings > Editor > Live Templates'.

Also, you can restore the built-in templates there if any problems occur after the import.

About

Android Studio Live Templates for Logging in Kotlin (Timber Log)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published