
Do we (android developers) know the power of Logcat?
Yes, It is class, tool or functionality in android to print log in Logcat view, some time for try and error or for debugging purpose we used Log. For example, when I started development in android I used it for whether or not button click work, to check API response, to check variable values. And there are many other scenarios where we used logcat in Android.
Have you ever face any difficulties?
Yes and No both, let me explain. We generally used Log.e, Log.d, Log.i, etc to print a log, It takes two arguments first is tag and second is a message we want to print in log cat. Many times I print response of API and used the same tag “response” as the first argument of Log. Tag “response” used to identify responses from another printed log from the logcat. However, sometimes I get confused about which response print from which method and class. I didn’t say it’s log cat issue, as general programmer or fresher level developer do that.
Okay, enough story but where is the power as per the title.
What if we can link printed logcat message from where it is printed. That sounds greats and looks like power, isn’t it? That will help to identify from where ‘xyz’ message printed.
How can I link a logcat message to its class and method?
Here are tiny libs I have developed to link logcat messages to its calling parents. It’s very small and easy to integrate. Just implement below Gradle into your project.
Simple add below gradle to your project and start log message as you do.
How to use it, is it difficult to use?
Very simple to use it. as simple as use Log.e, Log.d, etc. Just remember you have import class from above library. Check below code.
As simple as that.