Skip to content

Instantly share code, notes, and snippets.

@nodinosaur
Last active September 28, 2017 12:00
Show Gist options
  • Save nodinosaur/f92773a5ff331dab58bf1baa00c37d1a to your computer and use it in GitHub Desktop.
Save nodinosaur/f92773a5ff331dab58bf1baa00c37d1a to your computer and use it in GitHub Desktop.
Timber debug Tree that has a clickable Android Studio Link
package xyz.androidalliance.logs
import timber.log.Timber
class AndroidDebugTree : Timber.DebugTree() {
override fun createStackElementTag(element: StackTraceElement): String {
// returns a clickable Android Studio link
return String.format("\n%4\$s .%1\$s(%2\$s:%3\$s)\n\n",
element.methodName,
element.fileName,
element.lineNumber,
super.createStackElementTag(element))
}
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
println(String.format("%2\$s %1\$s", tag, message))
t?.printStackTrace(System.out)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment