Skip to content

Commit 7a026d6

Browse files
suhsteveimback82
authored andcommitted
Expose SparkContext.setLogLevel API (#360)
1 parent 3eb6fab commit 7a026d6

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/csharp/Microsoft.Spark.E2ETest/IpcTests/SparkContextTests.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System;
56
using Microsoft.Spark.E2ETest.Utils;
67
using Xunit;
78

@@ -21,11 +22,15 @@ public void TestSignaturesV2_3_X()
2122
{
2223
SparkContext sc = SparkContext.GetOrCreate(new SparkConf());
2324

24-
_ = sc.GetConf();
25-
_ = sc.DefaultParallelism;
25+
Assert.IsType<SparkConf>(sc.GetConf());
26+
Assert.IsType<int>(sc.DefaultParallelism);
2627

2728
sc.SetJobDescription("job description");
2829

30+
sc.SetLogLevel("ALL");
31+
sc.SetLogLevel("debug");
32+
Assert.Throws<Exception>(() => sc.SetLogLevel("INVALID"));
33+
2934
sc.SetJobGroup("group id", "description");
3035
sc.SetJobGroup("group id", "description", true);
3136

@@ -35,10 +40,8 @@ public void TestSignaturesV2_3_X()
3540
sc.AddFile(filePath);
3641
sc.AddFile(filePath, true);
3742

38-
using (var tempDir = new TemporaryDirectory())
39-
{
40-
sc.SetCheckpointDir(TestEnvironment.ResourceDirectory);
41-
}
43+
using var tempDir = new TemporaryDirectory();
44+
sc.SetCheckpointDir(TestEnvironment.ResourceDirectory);
4245
}
4346
}
4447
}

src/csharp/Microsoft.Spark/SparkContext.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,18 @@ public static SparkContext GetOrCreate(SparkConf conf)
121121
conf));
122122
}
123123

124+
/// <summary>
125+
/// Control our logLevel. This overrides any user-defined log settings.
126+
/// </summary>
127+
/// <remarks>
128+
/// Valid log levels include: ALL, DEBUG, ERROR, FATAL, INFO, OFF, TRACE, WARN
129+
/// </remarks>
130+
/// <param name="logLevel">The desired log level as a string.</param>
131+
public void SetLogLevel(string logLevel)
132+
{
133+
_jvmObject.Invoke("setLogLevel", logLevel);
134+
}
135+
124136
/// <summary>
125137
/// Shut down the SparkContext.
126138
/// </summary>

0 commit comments

Comments
 (0)