Francisco Noriega
Francisco Noriega

Reputation: 14614

Is there any way to add a listener to android.util.log?

I want to do some extra stuff with my logs on debug build. Currently the app is using android.util.Log class (e.g. Log.w(TAG, "msg");directly, and they in turn appear in logcat.

Is there any way to capture stuff that is sent to logcat? Or is the only way to create a wrapper logger than executes my extra stuff and then calls to util.Log?

Upvotes: 2

Views: 1311

Answers (1)

Xenolion
Xenolion

Reputation: 12735

  • You can extend the class Log yourself and add your own listeners ( interfaces and probably send local broadcasts and receive using Android BroadcastReceivers) and respond to the information sent the way you want to.

  • Or if you dont want to reinvent the wheel you can explore some third party libraries like these first, second and third and probably a lot more. Many support printing the Logs too and more!.

Upvotes: 2

Related Questions