This is an automated email from the ASF dual-hosted git repository.
gurwls223 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 9bab16a854d8 [MINOR][TESTS] Use SparkContext.setLogLevel in QuietTest
9bab16a854d8 is described below
commit 9bab16a854d8c4e6decbb8812b332ae5e8825993
Author: Hyukjin Kwon <[email protected]>
AuthorDate: Tue Nov 26 18:03:49 2024 +0900
[MINOR][TESTS] Use SparkContext.setLogLevel in QuietTest
### What changes were proposed in this pull request?
This PR proposes to use SparkContext.setLogLevel in QuietTest
### Why are the changes needed?
To avoid the direct update of logger but reuses SparkContext.setLogLevel.
### Does this PR introduce _any_ user-facing change?
No, test-only.
### How was this patch tested?
Manually tested.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #48966 from HyukjinKwon/minor-log-level.
Authored-by: Hyukjin Kwon <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
---
python/pyspark/testing/utils.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/python/pyspark/testing/utils.py b/python/pyspark/testing/utils.py
index 1dd15666382f..9ac0c9ba7399 100644
--- a/python/pyspark/testing/utils.py
+++ b/python/pyspark/testing/utils.py
@@ -192,14 +192,16 @@ def eventually(
class QuietTest:
def __init__(self, sc):
- self.log4j = sc._jvm.org.apache.log4j
+ self.sc = sc
def __enter__(self):
- self.old_level = self.log4j.LogManager.getRootLogger().getLevel()
- self.log4j.LogManager.getRootLogger().setLevel(self.log4j.Level.FATAL)
+ self.old_level = (
+
self.sc._jvm.org.apache.log4j.LogManager.getRootLogger().getLevel().toString()
+ )
+ self.sc.setLogLevel("FATAL")
def __exit__(self, exc_type, exc_val, exc_tb):
- self.log4j.LogManager.getRootLogger().setLevel(self.old_level)
+ self.sc.setLogLevel(self.old_level)
class PySparkTestCase(unittest.TestCase):
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]