Skip to content

Instantly share code, notes, and snippets.

@ahmed-shehataa
Last active October 1, 2020 14:39
Show Gist options
  • Save ahmed-shehataa/87027666022e9c1efcc492084fb78fab to your computer and use it in GitHub Desktop.
Save ahmed-shehataa/87027666022e9c1efcc492084fb78fab to your computer and use it in GitHub Desktop.
A custom class to use log only in debug mode not release.
class Logger {
companion object {
private val isDebug = BuildConfig.DEBUG
@JvmStatic
fun e(tag: String, message: String) {
if (isDebug) {
Log.e(tag, message)
}
}
@JvmStatic
fun v(tag: String, message: String) {
if (isDebug) {
Log.v(tag, message)
}
}
@JvmStatic
fun d(tag: String, message: String) {
if (isDebug) {
Log.d(tag, message)
}
}
@JvmStatic
fun i(tag: String, message: String) {
if (isDebug) {
Log.i(tag, message)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment