Unfortunately it looks like you directly can't do that for typical Log calls (.d
, .i
, .w
). If you look at the source code of the Log
class (https://android.googlesource.com/platform/frameworks/base/+/android-4.3_r2.1/core/java/android/util/Log.java) you'll see that these calls are just translated into a println_native
, a private function mapped to a native implementation.
Also, the Log class is final, so you can't extend it and hook into .d
, .i
, .e
, .w
I'm afraid your only solution is to write a Log
class wrapper if you need to capture those calls. This will work for your custom Log's but obviously not for the system-issued calls to the Log
class.
But good news is there's a special Log
function that allows listeners. There's a funny method on the Log
class:
public static TerribleFailureHandler setWtfHandler(TerribleFailureHandler handler)
And you can set a handler that will be called when you do
Log.wtf (TAG, message)
funny google method names :)