
io.github.numichi.reactive.logger.reactor.MDCSnapshot.kt Maven / Gradle / Ivy
package io.github.numichi.reactive.logger.reactor
import org.slf4j.MDC
class MDCSnapshot private constructor(context: Map?) : AutoCloseable {
companion object {
@JvmStatic
fun of(context: Map?): MDCSnapshot {
return MDCSnapshot(context)
}
@JvmStatic
fun empty(): MDCSnapshot {
return MDCSnapshot(null)
}
}
init {
if (context == null) {
close()
} else {
MDC.setContextMap(context)
}
}
val copyOfContextMap: Map
get() = MDC.getCopyOfContextMap()
override fun close() {
MDC.clear()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy