Github user aarondav commented on a diff in the pull request:
https://github.com/apache/spark/pull/332#discussion_r11331064
--- Diff: core/src/main/scala/org/apache/spark/Logging.scala ---
@@ -30,65 +30,66 @@ trait Logging {
// Make the log field transient so that objects with Logging can
// be serialized and used on another machine
@transient private var log_ : Logger = null
+ @transient protected var logName_ : String = null
// Method to get or create the logger for this object
protected def log: Logger = {
if (log_ == null) {
initializeIfNecessary()
- var className = this.getClass.getName
+ var className = if(logName_ == null) this.getClass.getName else
logName_
// Ignore trailing $'s in the class names for Scala objects
if (className.endsWith("$")) {
className = className.substring(0, className.length - 1)
}
- log_ = LoggerFactory.getLogger(className)
+ log_ = Logger(LoggerFactory.getLogger(className))
}
log_
}
// Log methods that take only a String
protected def logInfo(msg: => String) {
- if (log.isInfoEnabled) log.info(msg)
+ log.info(msg)
}
protected def logDebug(msg: => String) {
- if (log.isDebugEnabled) log.debug(msg)
+ log.debug(msg)
--- End diff --
This could cause a significant performance hit. Previously, we would not
evaluate the "msg" function unless the specified level was enabled, which
allows us to avoid string building and calling various toString methods when
the log messages won't be seen. Can we re-add these checks using
`log.underlying`?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---