You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by da...@apache.org on 2016/04/22 01:09:55 UTC

spark git commit: [SPARK-14780] [R] Add `setLogLevel` to SparkR

Repository: spark
Updated Branches:
  refs/heads/master f82aa8248 -> 411454475


[SPARK-14780] [R] Add `setLogLevel` to SparkR

## What changes were proposed in this pull request?

This PR aims to add `setLogLevel` function to SparkR shell.

**Spark Shell**
```scala
scala> sc.setLogLevel("ERROR")
```

**PySpark**
```python
>>> sc.setLogLevel("ERROR")
```

**SparkR (this PR)**
```r
> setLogLevel(sc, "ERROR")
NULL
```

## How was this patch tested?

Pass the Jenkins tests including a new R testcase.

Author: Dongjoon Hyun <do...@apache.org>

Closes #12547 from dongjoon-hyun/SPARK-14780.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/41145447
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/41145447
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/41145447

Branch: refs/heads/master
Commit: 411454475a031869eb7dc0c5fd84f41b3fdfa295
Parents: f82aa82
Author: Dongjoon Hyun <do...@apache.org>
Authored: Thu Apr 21 16:09:50 2016 -0700
Committer: Davies Liu <da...@gmail.com>
Committed: Thu Apr 21 16:09:50 2016 -0700

----------------------------------------------------------------------
 R/pkg/NAMESPACE                          |  3 +++
 R/pkg/R/context.R                        | 17 +++++++++++++++++
 R/pkg/inst/tests/testthat/test_context.R |  5 +++++
 3 files changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/41145447/R/pkg/NAMESPACE
----------------------------------------------------------------------
diff --git a/R/pkg/NAMESPACE b/R/pkg/NAMESPACE
index 667fff7..b3aff10 100644
--- a/R/pkg/NAMESPACE
+++ b/R/pkg/NAMESPACE
@@ -24,6 +24,9 @@ export("setJobGroup",
        "clearJobGroup",
        "cancelJobGroup")
 
+# Export Utility methods
+export("setLogLevel")
+
 exportClasses("DataFrame")
 
 exportMethods("arrange",

http://git-wip-us.apache.org/repos/asf/spark/blob/41145447/R/pkg/R/context.R
----------------------------------------------------------------------
diff --git a/R/pkg/R/context.R b/R/pkg/R/context.R
index b0e67c8..4105a6e 100644
--- a/R/pkg/R/context.R
+++ b/R/pkg/R/context.R
@@ -225,3 +225,20 @@ broadcast <- function(sc, object) {
 setCheckpointDir <- function(sc, dirName) {
   invisible(callJMethod(sc, "setCheckpointDir", suppressWarnings(normalizePath(dirName))))
 }
+
+#' Set new log level
+#'
+#' Set new log level: "ALL", "DEBUG", "ERROR", "FATAL", "INFO", "OFF", "TRACE", "WARN"
+#'
+#' @rdname setLogLevel
+#' @param sc Spark Context to use
+#' @param level New log level
+#' @export
+#' @examples
+#'\dontrun{
+#' setLogLevel(sc, "ERROR")
+#'}
+
+setLogLevel <- function(sc, level) {
+  callJMethod(sc, "setLogLevel", level)
+}

http://git-wip-us.apache.org/repos/asf/spark/blob/41145447/R/pkg/inst/tests/testthat/test_context.R
----------------------------------------------------------------------
diff --git a/R/pkg/inst/tests/testthat/test_context.R b/R/pkg/inst/tests/testthat/test_context.R
index 9f51161..ffa067e 100644
--- a/R/pkg/inst/tests/testthat/test_context.R
+++ b/R/pkg/inst/tests/testthat/test_context.R
@@ -90,6 +90,11 @@ test_that("job group functions can be called", {
   clearJobGroup(sc)
 })
 
+test_that("utility function can be called", {
+  sc <- sparkR.init()
+  setLogLevel(sc, "ERROR")
+})
+
 test_that("getClientModeSparkSubmitOpts() returns spark-submit args from whitelist", {
   e <- new.env()
   e[["spark.driver.memory"]] <- "512m"


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org