withLoggingContext

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

Use a pair in MDC context. Example:

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

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

Use a vary number of pairs in MDC context. Example:

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

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

Use a map in MDC context. Example:

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