Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement Log.withMdc for creating Log with MDC preset #250

Merged
merged 1 commit into from
Nov 29, 2023

Conversation

dfakhritdinov
Copy link
Contributor

No description provided.

@dfakhritdinov dfakhritdinov merged commit 5f7b9b0 into master Nov 29, 2023
6 of 7 checks passed
@mikost
Copy link

mikost commented Nov 29, 2023

Edit: Oh, now I see - the withMDC on line 144 is an internal implementation detail, not available to the user of the class.

Original comment:
On line 144 in the changed file, Log.scala, there was already a similar, albeit slightly different, method:

    def withMDC(mdc: Log.Mdc)(log: => Unit): Unit = {
      import Mdc.MdcOps
      mdc.context match {
        case None => log
        case Some(mdc) =>
          val backup = MDC.getCopyOfContextMap
          MDC.clear()
          mdc.toSortedMap foreach { case (k, v) => MDC.put(k, v) }
          log
          if (backup == null) MDC.clear() else MDC.setContextMap(backup)
      }
    }

I can't immediately discern whether that's for the same use case (as was catered for in this MR) or another one. Can you elaborate, please? Perhaps some ScalaDoc-ing is warranted for these two? Or one of them should be deprecated?

dfakhritdinov added a commit that referenced this pull request Nov 29, 2023
Co-authored-by: Denys Fakhritdinov <dfakhritdinov@evolution.com>
@dfakhritdinov dfakhritdinov deleted the df/log-with-preset-mdc branch February 1, 2024 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants