-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
Description
Currently CoroutineContext#DEBUG
rely on system property kotlinx.coroutines.debug
.
private const val DEBUG_PROPERTY_NAME = "kotlinx.coroutines.debug"
private val DEBUG = run {
val value = try { System.getProperty(DEBUG_PROPERTY_NAME) }
catch (e: SecurityException) { null }
when (value) {
"auto", null -> CoroutineId::class.java.desiredAssertionStatus()
"on", "" -> true
"off" -> false
else -> error("System property '$DEBUG_PROPERTY_NAME' has unrecognized value '$value'")
}
}
In Android we usually rely on BuildConfig.DEBUG
flag which indicate if app was build in debug or production mode.
Currently to set CoroutineContext#DEBUG
value we need to use following code:
System.setProperty("kotlinx.coroutines.debug", if (BuildConfig.DEBUG) "on" else "off")
Which is not type safe, so my proposal is to:
- make
CoroutineContext#DEBUG_PROPERTY_NAME
public, also move "on", "off", "auto" to public constants as well - or make alternative, simpler mechanism to change
CoroutineContext#DEBUG
value