-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-47598][CORE] MLLib: Migrate logError with variables to structured logging framework #45837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
05127ba
cf22181
c46a601
7b4fe42
46d2fd6
5b4f2a1
7dfa115
27f8d05
01a8303
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,7 +117,7 @@ trait Logging { | |
| } | ||
| } | ||
|
|
||
| private def withLogContext(context: java.util.HashMap[String, String])(body: => Unit): Unit = { | ||
| protected def withLogContext(context: java.util.HashMap[String, String])(body: => Unit): Unit = { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why change |
||
| val threadContext = CloseableThreadContext.putAll(context) | ||
| try { | ||
| body | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,7 @@ import org.json4s._ | |
| import org.json4s.JsonDSL._ | ||
| import org.json4s.jackson.JsonMethods._ | ||
|
|
||
| import org.apache.spark.internal.Logging | ||
| import org.apache.spark.internal.{LogEntry, Logging} | ||
| import org.apache.spark.ml.{MLEvents, PipelineStage} | ||
| import org.apache.spark.ml.param.{Param, Params} | ||
| import org.apache.spark.rdd.RDD | ||
|
|
@@ -84,20 +84,53 @@ private[spark] class Instrumentation private () extends Logging with MLEvents { | |
| super.logWarning(prefix + msg) | ||
| } | ||
|
|
||
| /** | ||
| * Logs a LogEntry which message with a prefix that uniquely identifies the training session. | ||
| */ | ||
| override def logWarning(entry: LogEntry): Unit = { | ||
| if (log.isWarnEnabled) { | ||
| withLogContext(entry.context) { | ||
| log.warn(prefix + entry.message) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Logs a error message with a prefix that uniquely identifies the training session. | ||
| */ | ||
| override def logError(msg: => String): Unit = { | ||
| super.logError(prefix + msg) | ||
| } | ||
|
|
||
| /** | ||
| * Logs a LogEntry which message with a prefix that uniquely identifies the training session. | ||
| */ | ||
| override def logError(entry: LogEntry): Unit = { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can write it as follows: But it seems that the |
||
| if (log.isErrorEnabled) { | ||
| withLogContext(entry.context) { | ||
| log.error(prefix + entry.message) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Logs an info message with a prefix that uniquely identifies the training session. | ||
| */ | ||
| override def logInfo(msg: => String): Unit = { | ||
| super.logInfo(prefix + msg) | ||
| } | ||
|
|
||
| /** | ||
| * Logs a LogEntry which message with a prefix that uniquely identifies the training session. | ||
| */ | ||
| override def logInfo(entry: LogEntry): Unit = { | ||
| if (log.isInfoEnabled) { | ||
| withLogContext(entry.context) { | ||
| log.info(prefix + entry.message) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Logs the value of the given parameters for the estimator being used in this session. | ||
| */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: let's sort the keys.