Better debugging with the help of Live Templates

MahmoudMabrouk(mo3ta)
2 min readJul 22, 2021

--

One of most tools we used for debugging is Logcat, But we end with a huge amount of logs which most of them not related to our debugging.

See the problem

Even we are using the app PackageName, it does not help us to filter out unnecessary logs.

Solution? Live Templates.

with help of Live Templates, we can make debugging more easier.

Let’s create it

Settings -> Editor -> Live Templates -> AndroidLog

Settings -> Editor -> Live Templates -> AndroidLog

then click on ‘+’ and choose lt

then add this template

using $ANY_NAME$ will define a variable that will be filled using an expression, see next screen

class -> will be replaced at log message with class name
method -> will be replaced at log message with the method name

We can use our Live Template by write mylog + (click)Tab

Result

Note: Do not forget to import Log `import android.util.Log`

Our Logcat

with above Live Templates, it helped us to
1- Easy filter out our logs at Logcat.
2- Have class name so we can know Fragment/Activity/Class that publish this log
3- Have the name of the function that publishes this log.

Have nice debugging.

--

--