gengliangwang commented on code in PR #45729:
URL: https://github.com/apache/spark/pull/45729#discussion_r1540122275


##########
common/utils/src/main/scala/org/apache/spark/internal/Logging.scala:
##########
@@ -55,6 +76,37 @@ trait Logging {
     log_
   }
 
+  implicit class LogStringContext(val sc: StringContext) {
+    def log(args: Any*): (String, Instance) = {
+      val processedParts = sc.parts.iterator
+      val sb = new StringBuilder(processedParts.next())
+      lazy val map = new java.util.HashMap[String, String]()
+
+      args.foreach { arg =>
+        arg match {
+          case mdc: MDC =>
+            sb.append(mdc.value)
+            if (Logging.isStructuredLoggingEnabled) {
+              map.put(mdc.key.toString.toLowerCase(Locale.ROOT), mdc.value)
+            }
+          case other =>
+            throw new IllegalArgumentException(s"Argument $other is not a MDC")

Review Comment:
   Good point. I am changing it to an error which only happens during testing. 
So I don't think we need an error class here.



-- 
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

Reply via email to