withLoggingContextAsync

inline suspend fun <T> withLoggingContextAsync(    pair: Pair<String, String?>,     restorePrevious: Boolean = true,     crossinline body: suspend () -> T): T

Use a pair in an asynchronous MDC context. Example:

withLoggingContextAsync("userId" to userId) {
doSomething()
}
withLoggingContextAsync("userId" to userId, restorePrevious = false) {
doSomething()
}

inline suspend fun <T> withLoggingContextAsync(    vararg pair: Pair<String, String?>,     restorePrevious: Boolean = true,     crossinline body: suspend () -> T): T

Use a varying number of pairs in an asynchronous MDC context. Example:

withLoggingContextAsync("userId" to userId) {
doSomething()
}

inline suspend fun <T> withLoggingContextAsync(    map: Map<String, String?>,     restorePrevious: Boolean = true,     crossinline body: suspend () -> T): T

Use a map in an asynchronous MDC context. Example:

withLoggingContextAsync(mapOf("userId" to userId)) {
doSomething()
}
withLoggingContextAsync(mapOf("userId" to userId), restorePrevious = true) {
doSomething()
}