Skip to content

Commit

Permalink
Close #442 - [logger-f-logback-mdc-monix3] Rename MonixMdcAdapter to …
Browse files Browse the repository at this point in the history
…Monix3MdcAdapter
  • Loading branch information
kevin-lee committed Jul 14, 2023
1 parent e1bc86c commit 5ef9652
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import scala.jdk.CollectionConverters._
/** @author Kevin Lee
* @since 2023-02-18
*/
class MonixMdcAdapter extends JLoggerFMdcAdapter {
class Monix3MdcAdapter extends JLoggerFMdcAdapter {

private[this] val localContext: Local[Map[String, String]] =
Local[Map[String, String]](Map.empty[String, String])
Expand Down Expand Up @@ -38,13 +38,13 @@ class MonixMdcAdapter extends JLoggerFMdcAdapter {
override def getKeys: JSet[String] = localContext().keySet.asJava

}
object MonixMdcAdapter {
object Monix3MdcAdapter {

@SuppressWarnings(Array("org.wartremover.warts.Null"))
def initialize(): MonixMdcAdapter = {
def initialize(): Monix3MdcAdapter = {
val field = classOf[MDC].getDeclaredField("mdcAdapter")
field.setAccessible(true)
val adapter = new MonixMdcAdapter
val adapter = new Monix3MdcAdapter
field.set(null, adapter) // scalafix:ok DisableSyntax.null
field.setAccessible(false)
adapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import scala.jdk.CollectionConverters._
/** @author Kevin Lee
* @since 2023-07-03
*/
object MonixMdcAdapterSpec extends Properties {
object Monix3MdcAdapterSpec extends Properties {

/*
* Task.defaultOptions.enableLocalContextPropagation is the same as
* sys.props.put("monix.environment.localContextPropagation", "1")
*/
implicit val opts: Task.Options = Task.defaultOptions.enableLocalContextPropagation
private val monixMdcAdapter: MonixMdcAdapter = MonixMdcAdapter.initialize()
implicit val opts: Task.Options = Task.defaultOptions.enableLocalContextPropagation
private val monixMdcAdapter: Monix3MdcAdapter = Monix3MdcAdapter.initialize()

override def tests: List[Test] = List(
property("Task - MDC should be able to put and get a value", testPutAndGet),
Expand Down

0 comments on commit 5ef9652

Please sign in to comment.