Nikky
11/12/2020, 11:04 AMprivate val exceptionHandler = CoroutineExceptionHandler { context, e -> GlobalScope.launch(MDCContext() + context) {
can i somehow do context.getCopyOfContextMap()
?oshai
11/12/2020, 7:44 PMNikky
11/12/2020, 7:52 PMMDC.put("extra", "value")
inside the coroutineScope and before a suspending call
then after that call the new value will be gone
so i tried something where i manually "save" the MDC state to the coroutineContext
fun CoroutineScope.storeMDC() {
<http://logger.info|logger.info> { "storeMDC" }
coroutineContext[MyMDCContext.Key]?.apply {
contextMap = MDC.getCopyOfContextMap()
}
}
but this does not work.. first of all contextMap
is readonly
and even when i made a copy of the class (MyMDCContext
) it does not work.. something still restores a empty MDC context after a suspending callwithContext(MDCContext()) { ... }
causing very indented code even fasteroshai
11/12/2020, 7:55 PMNikky
11/12/2020, 7:58 PMoshai
11/12/2020, 8:55 PMNikky
11/13/2020, 3:24 PM