Created
February 12, 2022 18:57
-
-
Save alexstyl/15c1ebe8877faf2847f32e09b2513afa to your computer and use it in GitHub Desktop.
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
import android.util.Log | |
object Logs { | |
var isLoggingEnabled = false | |
private const val TAG = "Logs" | |
private const val PREFIX = ">>>PREFIX:" | |
fun verboseln(message: () -> String) { | |
if (isLoggingEnabled) { | |
Log.v(TAG, "$PREFIX ${message.invoke()}") | |
} | |
} | |
fun debugln(message: () -> String) { | |
if (isLoggingEnabled) { | |
Log.d(TAG, "$PREFIX ${message.invoke()}") | |
} | |
} | |
fun infoln(message: () -> String) { | |
if (isLoggingEnabled) { | |
Log.i(TAG, "$PREFIX ${message.invoke()}") | |
} | |
} | |
fun warningln(message: () -> String) { | |
if (isLoggingEnabled) { | |
Log.w(TAG, "$PREFIX ${message.invoke()}") | |
} | |
} | |
fun warningln(error: Throwable) { | |
if (isLoggingEnabled) { | |
error.printStackTrace() | |
} | |
} | |
fun errorln(message: () -> String) { | |
if (isLoggingEnabled) { | |
Log.e(TAG, "$PREFIX ${message.invoke()}") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment