Skip to content

Instantly share code, notes, and snippets.

@GregKluska
Last active November 27, 2020 09:35
Show Gist options
  • Select an option

  • Save GregKluska/03abc68169722f98e34267687512b4b8 to your computer and use it in GitHub Desktop.

Select an option

Save GregKluska/03abc68169722f98e34267687512b4b8 to your computer and use it in GitHub Desktop.
TAG extension
/**
* extension function to provide TAG value
*/
val Any.TAG: String
get() {
return if (!javaClass.isAnonymousClass) {
val name = javaClass.simpleName
if (name.length <= 23) name else name.substring(0, 23)// first 23 chars
} else {
val name = javaClass.name
if (name.length <= 23) name else name.substring(name.length - 23, name.length)// last 23 chars
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment