Skip to content

Commit

Permalink
Only allow valid log levels, throw exception if invalid log level.
Browse files Browse the repository at this point in the history
  • Loading branch information
holdenk committed May 1, 2015
1 parent 338d7bf commit 9117244
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
6 changes: 5 additions & 1 deletion core/src/main/scala/org/apache/spark/SparkContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,13 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli
/** Control our logLevel. This overrides any user-defined log settings.
* @param logLevel The desired log level as a string.
* Valid log levels include: ALL, DEBUG, ERROR, FATAL, INFO, OFF, TRACE, WARN
* Invalid log level defaults to DEBUG
*/
def setLogLevel(logLevel: String) {
val logLevels = Seq("ALL", "DEBUG", "ERROR", "FATAL", "INFO", "OFF", "TRACE", "WARN")
if (!logLevels.contains(logLevel)) {
throw new InvalidArgumentException(
s"Supplied level $logLevel did not match one of: ${validLevels.mkString(',')}")
}
Utils.setLogLevel(org.apache.log4j.Level.toLevel(logLevel))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,6 @@ class JavaSparkContext(val sc: SparkContext)
/** Control our logLevel. This overrides any user-defined log settings.
* @param logLevel The desired log level as a string.
* Valid log levels include: ALL, DEBUG, ERROR, FATAL, INFO, OFF, TRACE, WARN
* Invalid log level defaults to DEBUG
*/
def setLogLevel(logLevel: String) {
sc.setLogLevel(logLevel)
Expand Down
1 change: 0 additions & 1 deletion python/pyspark/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ def setLogLevel(self, logLevel):
"""
Control our logLevel. This overrides any user-defined log settings.
Valid log levels include: ALL, DEBUG, ERROR, FATAL, INFO, OFF, TRACE, WARN
Invalid log level defaults to DEBUG
"""
self._jsc.setLogLevel(logLevel)

Expand Down

0 comments on commit 9117244

Please sign in to comment.