Have you ever add Log.d(TAG, message) to your Android app code just TEMPORARILY just to know a function has been reached? Or to watch a variable’s value, or count how many times a function has been reached?

After doing, then have to remove them and recompile everything again.

There’s 3 tricks below that could help you avoid need to code Log and compile and also no need to wait the breakpoint to stop.

1. “Breakpoint hit” message

Do the below if you just want to see that a function has been reached

Right click on the breakpoint of where you want to have that print out.

Then uncheck the Suspend so that the break point doesn’t get stop when it is reached.

Once the Suspend is unchecked, more options will appear below. Just checked the “breakpoint hit” message. That’s it!

Run with debugger attached (Debug Mode), and you could check the Console of the Debug View, you’ll see the Breakpoint reached at … if the code has been triggered.

Note: If you like to see the Stacktrace together,you could just check the Stacktrace too.

2. Evaluate and log

If you want to Log something out that is more complicated (not just “I am here” type), like watching a variable value out. But that log code is really temporary. Just do the below

Right click on the breakpoint of where you want to have that print out.

Then uncheck the Suspend so that the break point doesn’t get stop when it is reached.

Once the Suspend is unchecked, more options will appear below. Just checked the Evaluate and log, and add the relevant code with Log as shown below. That’s it!

Run with debugger attached (Debug Mode), and you could check the Logcat View. Filter it according to your TAG, and you’ll see it.

3. Overhead panel

Let’s assume you like to do something more complicated, like counting how many times a function has been reached. The above Evaluate and log can no longer do that. However cheer up, there’s and Overhead panel that you could see

It is normally in the Right side of the Debug View, and it will log

How many times a breakpoint has been hit

How much time a breakpoint overhead used (in case you’ll evaluating performance)

With this in places, you don’t need to explicitly write Log to your code to do that.