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


##########
common/utils/src/main/scala/org/apache/spark/internal/Logging.scala:
##########
@@ -43,19 +43,33 @@ case class MDC(key: LogKey, value: Any)
  * Wrapper class for log messages that include a logging context.
  * This is used as the return type of the string interpolator 
`LogStringContext`.
  */
-case class MessageWithContext(message: String, context: 
java.util.HashMap[String, String]) {
+case class MessageWithContext(
+    message: String,
+    context: java.util.HashMap[String, String],
+    stripMarginFromMessage: Boolean = false) {
   def +(mdc: MessageWithContext): MessageWithContext = {
     val resultMap = new java.util.HashMap(context)
     resultMap.putAll(mdc.context)
-    MessageWithContext(message + mdc.message, resultMap)
+    MessageWithContext(
+      message + mdc.message,
+      resultMap,
+      mdc.stripMarginFromMessage || stripMarginFromMessage)
   }
+
+  def stripMargin: MessageWithContext = copy(stripMarginFromMessage = true)

Review Comment:
   We can also have
   ```
   def stripMargin: MessageWithContext = copy(message = message.stripMargin)
   ```
   so that we don't need a boolean flag stripMarginFromMessage



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to