Last active
November 15, 2019 08:29
-
-
Save dakatso/10f8ab385e9c20cb2b4427952055e8b3 to your computer and use it in GitHub Desktop.
Koltin android log extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun klog(@IntRange(from = 2, to = 6) level: Int, message: Any?) { | |
if (!BuildConfig.DEBUG) return | |
Throwable().stackTrace[1].run { | |
val tag = "commontag" | |
val fullMessage = "($fileName:$lineNumber): $message" | |
when (level) { | |
Log.VERBOSE -> Log.v(tag, fullMessage) | |
Log.DEBUG -> Log.d(tag, fullMessage) | |
Log.INFO -> Log.i(tag, fullMessage) | |
Log.WARN -> Log.w(tag, fullMessage) | |
Log.ERROR -> Log.e(tag, fullMessage) | |
else -> throw IllegalArgumentException() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment