Код: Выделить всё
@JvmInline
value class MyLogger(private val tag: String) {
fun log(level: Level, e: Throwable? = null, message: String) {
if (isLoggingEnabled(level)) {
val logTime = System.currentTimeMillis()
val messageWithCoroutineInfo = "Running on: [${Thread.currentThread().name}] | $message"
when (level) {
Level.VERBOSE -> Log.v(tag, messageWithCoroutineInfo, e)
Level.DEBUG -> Log.d(tag, messageWithCoroutineInfo, e)
Level.INFO -> Log.i(tag, messageWithCoroutineInfo, e)
Level.WARN -> Log.w(tag, messageWithCoroutineInfo, e)
Level.ERROR -> Log.e(tag, messageWithCoroutineInfo, e)
Level.ASSERT -> Log.wtf(tag, messageWithCoroutineInfo, e)
}
}
}
....
}
private val logger = MYLogger("Navigator")
logger.i { "goTo: $screen; backstack: [${backStack.joinToString()}]" }
< /code>
В функции Oncreate: < /p>
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
System.setProperty("kotlinx.coroutines.debug", if(!BuildTypes.isProduction) "on" else "off")
Подробнее здесь: https://stackoverflow.com/questions/794 ... g-function