Skip to content

Instantly share code, notes, and snippets.

@rubdottocom
Created February 21, 2018 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubdottocom/813feed86842d2d862f528fd8afde902 to your computer and use it in GitHub Desktop.
Save rubdottocom/813feed86842d2d862f528fd8afde902 to your computer and use it in GitHub Desktop.
Logs with links to source code using Awesome Console IntelliJ plugin
// Works with Awesome Console IntelliJ plugin
// https://plugins.jetbrains.com/plugin/7677-awesome-console
import timber.log.Timber // https://github.com/JakeWharton/timber
class AwesomeTimberLog {
fun doLogWithLinkToSourceCode() {
Timber.d("Hello World! - " + UtilsK.getLinkToSourceFile(Thread.currentThread().stackTrace[2]))
}
}
class UtilsK {
companion object {
/**
* ste should be Thread.currentThread().stackTrace[2])
*/
@JvmStatic
fun getLinkToSourceFile(ste: StackTraceElement): String {
return ste.fileName + ":" + ste.lineNumber
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment