小编San*_*K P的帖子

无法从静态上下文引用非静态方法 - Java 到 Kotlin - Android

我正在尝试在 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)

java logging static android kotlin

1
推荐指数
1
解决办法
1018
查看次数

标签 统计

android ×1

java ×1

kotlin ×1

logging ×1

static ×1