diff --git a/project/SparkBuild.scala b/project/SparkBuild.scala index d1b0ed953e30..e5c7c93d40fd 100644 --- a/project/SparkBuild.scala +++ b/project/SparkBuild.scala @@ -155,14 +155,18 @@ object SparkBuild extends PomBuild { // We special case the 'println' lint rule to only be a warning on compile, because adding // printlns for debugging is a common use case and is easy to remember to remove. val scalaStyleOnCompileConfig: String = { - val in = "scalastyle-config.xml" + val base_style_config = "scalastyle-config.xml" + val prod_style_config = "scalastyle-config-prod.xml" val out = "scalastyle-on-compile.generated.xml" val replacements = Map( """customId="println" level="error"""" -> """customId="println" level="warn"""" ) - val source = Source.fromFile(in) + val base_source = Source.fromFile(base_style_config) + val prod_source = Source.fromFile(prod_style_config) try { - var contents = source.getLines.mkString("\n") + val base_lines = base_source.getLines().toList.dropRight(1) + val prod_lines = prod_source.getLines().drop(23) + var contents = base_lines.mkString("\n") + "\n" + prod_lines.mkString("\n") for ((k, v) <- replacements) { require(contents.contains(k), s"Could not rewrite '$k' in original scalastyle config.") contents = contents.replace(k, v) @@ -173,7 +177,8 @@ object SparkBuild extends PomBuild { } out } finally { - source.close() + base_source.close() + prod_source.close() } } diff --git a/scalastyle-config-prod.xml b/scalastyle-config-prod.xml new file mode 100644 index 000000000000..2f9e0c04df08 --- /dev/null +++ b/scalastyle-config-prod.xml @@ -0,0 +1,31 @@ + + + + Scalastyle configuration for prod only + + + log(?:Info|Warning|Error)\((?:".*"\.format\(.*\)|s".*(?:\$|\+\s*[^\s"]).*"\)) + + Logging message should use log"..." instead of s"..." and variables should be wrapped in `MDC`s. + Refer to Structured Logging Framework guidelines in the file `internal/Logging.scala`. + + +