All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.numichi.reactive.logger.hook.MDCContextHook.kt Maven / Gradle / Ivy

package io.github.numichi.reactive.logger.hook

import io.github.numichi.reactive.logger.MDC
import io.github.numichi.reactive.logger.internal.toSafeMdcMap
import reactor.util.context.ContextView

class MDCContextHook(val position: Position, private val hook: (contextView: ContextView, MDC) -> Map) {
    constructor(hook: (ContextView, MDC) -> Map) : this(Position.AFTER, hook)

    internal fun hookEvent(
        contextView: ContextView,
        mdc: MDC,
    ): Map {
        return try {
            this.hook(contextView, mdc).toSafeMdcMap()
        } catch (e: Throwable) {
            mapOf()
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy