with Logging Context
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()
}
Content copied to clipboard
withLoggingContext("userId" to userId, restorePrevious = false) {
doSomething()
}
Content copied to clipboard
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()
}
Content copied to clipboard
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()
}
Content copied to clipboard
withLoggingContext(mapOf("userId" to userId), restorePrevious = true) {
doSomething()
}
Content copied to clipboard