pan3793 commented on code in PR #51775: URL: https://github.com/apache/spark/pull/51775#discussion_r2247532807
########## common/utils/src/main/scala/org/apache/spark/internal/Logging.scala: ########## @@ -182,6 +170,12 @@ trait Logging { } } + protected def MDC(key: LogKey, value: Any): MDC = { + require(!value.isInstanceOf[MessageWithContext], + "the class of value cannot be MessageWithContext") + new MDC(key, value) + } Review Comment: Since it's unable to write a class in Java that allows Scala to construct instances as same as Scala's `case class`, I create this method instead. So, for logging in Scala ```scala logInfo(log"Application ID is ${MDC(APP_ID, appId)}") ``` previously `MDC(APP_ID, appId)` calls `case class`'s constructor, now it calls this method. ########## common/utils/src/main/scala/org/apache/spark/internal/Logging.scala: ########## @@ -182,6 +170,12 @@ trait Logging { } } + protected def MDC(key: LogKey, value: Any): MDC = { Review Comment: Since it's unable to write a class in Java that allows Scala to construct instances as same as Scala's `case class`, I create this method instead. So, for logging in Scala ```scala logInfo(log"Application ID is ${MDC(APP_ID, appId)}") ``` previously `MDC(APP_ID, appId)` calls `case class`'s constructor, now it calls this method. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org