Skip to content

Feature: MDC support #31

@mkobit

Description

@mkobit

Consider adding some additional functions for managing MDC (Javadoc: https://www.slf4j.org/api/org/slf4j/MDC.html) by putting and removing keys

Additional consideration: it would be great to have it with coroutines

Docs: https://www.slf4j.org/manual.html#mdc

I don't have a concrete API proposal but here is some initial thoughts:

object MDC {
  // additional overloads for varargs and up to some N number of `Pair`
  fun <T> withContext(keyPair: Pair<String, String>, body: () -> T) {
    return org.slf4j.MDC.putCloseable(keyPair.first, keyPair.second).use {
      body()
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions