I asked the following question in Stack Overflow: https://stackoverflow.com/questions/54661138/how-to-get-current-coroutinecontext-from-a-non-suspend-function
But I am repeating here
I would like to get the current
coroutineContext inside a regular function declared as:
fun log(message: String)
If it is not running inside a coroutine I am fine will
Basically, instead of:
public suspend inline val coroutineContext: CoroutineContext
public inline val coroutineContext: CoroutineContext?
This is entirely for logging purposes. I need to log a certain element from the context (in some way this is similar how coroutine’s name is appended to
Thread.currentThread().name for debugging).
Is this possible? Thanks!