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


##########
common/utils/src/main/scala/org/apache/spark/internal/Logging.scala:
##########
@@ -127,95 +127,96 @@ trait Logging {
   }
 
   // Log methods that take only a String
-  protected def logInfo(msg: => String): Unit = {
-    if (log.isInfoEnabled) log.info(msg)
-  }
-
-  protected def logInfo(entry: LogEntry): Unit = {
-    if (log.isInfoEnabled) {
-      withLogContext(entry.context) {
-        log.info(entry.message)
-      }
-    }
-  }
-
-  protected def logInfo(entry: LogEntry, throwable: Throwable): Unit = {
-    if (log.isInfoEnabled) {
-      withLogContext(entry.context) {
-        log.info(entry.message, throwable)
-      }
-    }
-  }
-
-  protected def logDebug(msg: => String): Unit = {
-    if (log.isDebugEnabled) log.debug(msg)
-  }
-
-  protected def logTrace(msg: => String): Unit = {
-    if (log.isTraceEnabled) log.trace(msg)
-  }
-
-  protected def logWarning(msg: => String): Unit = {
-    if (log.isWarnEnabled) log.warn(msg)
-  }
-
-  protected def logWarning(entry: LogEntry): Unit = {
-    if (log.isWarnEnabled) {
-      withLogContext(entry.context) {
-        log.warn(entry.message)
-      }
-    }
-  }
+  protected def logDebug(msg: => String): Unit = if (log.isDebugEnabled) 
log.debug(msg)
+  protected def logError(msg: => String): Unit = if (log.isErrorEnabled) 
log.error(msg)
+  protected def logInfo(msg: => String): Unit = if (log.isInfoEnabled) 
log.info(msg)
+  protected def logTrace(msg: => String): Unit = if (log.isTraceEnabled) 
log.trace(msg)
+  protected def logWarning(msg: => String): Unit = if (log.isWarnEnabled) 
log.warn(msg)
+
+  // Log methods that take a string message and a Throwable (Exception/Error) 
too
+  protected def logDebug(msg: => String, throwable: Throwable): Unit =
+    if (log.isDebugEnabled) log.debug(msg, throwable)
+  protected def logError(msg: => String, throwable: Throwable): Unit =
+    if (log.isErrorEnabled) log.error(msg, throwable)
+  protected def logInfo(msg: => String, throwable: Throwable): Unit =
+    if (log.isInfoEnabled) log.info(msg, throwable)
+  protected def logTrace(msg: => String, throwable: Throwable): Unit =
+    if (log.isTraceEnabled) log.trace(msg, throwable)
+  protected def logWarning(msg: => String, throwable: Throwable): Unit =
+    if (log.isWarnEnabled) log.warn(msg, throwable)
 
-  protected def logWarning(entry: LogEntry, throwable: Throwable): Unit = {
-    if (log.isWarnEnabled) {
+  // Log methods that take only a LogEntry
+  protected def logDebug(entry: LogEntry): Unit = logDebug(entry, stripMargin 
= false)
+  protected def logError(entry: LogEntry): Unit = logError(entry, stripMargin 
= false)
+  protected def logInfo(entry: LogEntry): Unit = logInfo(entry, stripMargin = 
false)
+  protected def logTrace(entry: LogEntry): Unit = logTrace(entry, stripMargin 
= false)
+  protected def logWarning(entry: LogEntry): Unit = logWarning(entry, 
stripMargin = false)
+
+  // Log methods that take only a LogEntry and a Throwable (Exception/Error) 
too
+  protected def logDebug(entry: LogEntry, throwable: Throwable): Unit =
+    logDebug(entry, throwable, stripMargin = false)
+  protected def logError(entry: LogEntry, throwable: Throwable): Unit =
+    logError(entry, throwable, stripMargin = false)
+  protected def logInfo(entry: LogEntry, throwable: Throwable): Unit =
+    logInfo(entry, throwable, stripMargin = false)
+  protected def logTrace(entry: LogEntry, throwable: Throwable): Unit =
+    logTrace(entry, throwable, stripMargin = false)
+  protected def logWarning(entry: LogEntry, throwable: Throwable): Unit =
+    logWarning(entry, throwable, stripMargin = false)
+
+  // Log methods that take only a LogEntry with the option to strip margin 
from the string message
+  protected def logDebug(entry: LogEntry, stripMargin: Boolean): Unit =
+    logEntryHelper(entry, stripMargin, log.debug)
+  protected def logError(entry: LogEntry, stripMargin: Boolean): Unit =

Review Comment:
   We talked offline and decided to add a `stripMargin` method to the 
`MessageWithContext` class for this purpose.



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