Kotlin Android print to console

前端 未结 6 953
难免孤独
难免孤独 2021-02-03 17:54

I need to print some str to console (Android Studio) using Kotlin. I\'ve tried the:

Log.v() 
Log.d() 
Log.i() 
Log.w() 
Log.e() 

methods. But i

6条回答
  •  南笙
    南笙 (楼主)
    2021-02-03 17:58

    androidKotlin is deprecated and use Anko instead.

    https://github.com/Kotlin/anko/wiki/Anko-Commons-%E2%80%93-Logging

    class SomeActivity : Activity(), AnkoLogger {
        private fun someMethod() {
            info("London is the capital of Great Britain")
            debug(5) // .toString() method will be executed
            warn(null) // "null" will be printed
        }
    }
    

提交回复
热议问题