我正在尝试在 android 中创建一个 Logger 类,它仅在调试版本时才会记录消息。
object Logger2 {
private const val TAG = Constants.LOGGING_TAG
fun d(message : Any?){
if (BuildConfig.DEBUG)
Log.d(TAG , message.toString())
}
fun d(message: Any? , e : Exception?){
if (BuildConfig.DEBUG)
Log.d(TAG , message.toString(), e)
}
fun e(message : Any?){
if (BuildConfig.DEBUG)
Log.e(TAG , message.toString())
}
fun e(message: Any? , e : Exception?){
if (BuildConfig.DEBUG)
Log.e(TAG , message.toString(), e)
}
fun w(message : Any?){
if (BuildConfig.DEBUG)
Log.w(TAG , message.toString())
}
fun w(message: Any? , e : Exception?){
if …Run Code Online (Sandbox Code Playgroud)