Skip to content

Commit 83329e7

Browse files
committed
remove public from LoggingUtils.
1 parent a63d6fe commit 83329e7

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

oauth2_http/java/com/google/auth/oauth2/LoggingUtils.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
import org.slf4j.LoggerFactory;
1515
import org.slf4j.MDC;
1616

17-
public class LoggingUtils {
17+
class LoggingUtils {
1818

19-
private static final java.util.logging.Logger LOGGER =
20-
java.util.logging.Logger.getLogger(LoggingUtils.class.getName());
2119
private static EnvironmentProvider environmentProvider = SystemEnvironmentProvider.getInstance();
2220

2321
// expose this setter for testing purposes
@@ -38,11 +36,12 @@ public ILoggerFactory getLoggerFactory() {
3836
}
3937
}
4038

41-
public static Logger getLogger(Class<?> clazz) {
39+
static Logger getLogger(Class<?> clazz) {
4240
return getLogger(clazz, new DefaultLoggerFactoryProvider());
4341
}
4442

45-
public static Logger getLogger(Class<?> clazz, LoggerFactoryProvider factoryProvider) {
43+
// constructor with LoggerFactoryProvider to make testing easier
44+
static Logger getLogger(Class<?> clazz, LoggerFactoryProvider factoryProvider) {
4645
if (!isLoggingEnabled()) {
4746
// use SLF4j's NOP logger regardless of bindings
4847
return org.slf4j.helpers.NOPLogger.NOP_LOGGER;
@@ -57,12 +56,12 @@ public static Logger getLogger(Class<?> clazz, LoggerFactoryProvider factoryProv
5756
return org.slf4j.helpers.NOPLogger.NOP_LOGGER;
5857
}
5958

60-
public static boolean isLoggingEnabled() {
59+
static boolean isLoggingEnabled() {
6160
String enableLogging = environmentProvider.getEnv("GOOGLE_SDK_JAVA_LOGGING");
6261
return "true".equalsIgnoreCase(enableLogging);
6362
}
6463

65-
public static void logWithMDC(
64+
static void logWithMDC(
6665
Logger logger, org.slf4j.event.Level level, Map<String, String> contextMap, String message) {
6766
contextMap.forEach(MDC::put);
6867
switch (level) {

oauth2_http/javatests/com/google/auth/TestAppender.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
import java.util.ArrayList;
66
import java.util.List;
77

8-
/**
9-
* Logback appender used to set up tests.
10-
*/
8+
/** Logback appender used to set up tests. */
119
public class TestAppender extends AppenderBase<ILoggingEvent> {
1210
public static List<ILoggingEvent> events = new ArrayList<>();
1311

oauth2_http/javatests/com/google/auth/oauth2/ServiceAccountCredentialsTest.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@
4141
import static org.junit.Assert.assertTrue;
4242
import static org.junit.Assert.fail;
4343

44-
import ch.qos.logback.classic.LoggerContext;
45-
import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
46-
import ch.qos.logback.classic.spi.ILoggingEvent;
47-
import ch.qos.logback.core.ConsoleAppender;
4844
import com.google.api.client.http.HttpResponseException;
4945
import com.google.api.client.http.HttpStatusCodes;
5046
import com.google.api.client.json.GenericJson;
@@ -83,13 +79,10 @@
8379
import java.util.List;
8480
import java.util.Map;
8581
import java.util.concurrent.atomic.AtomicBoolean;
86-
import org.junit.After;
8782
import org.junit.Before;
8883
import org.junit.Test;
8984
import org.junit.runner.RunWith;
9085
import org.junit.runners.JUnit4;
91-
import org.slf4j.Logger;
92-
import org.slf4j.LoggerFactory;
9386

9487
/** Test case for {@link ServiceAccountCredentials}. */
9588
@RunWith(JUnit4.class)
@@ -167,6 +160,7 @@ private ServiceAccountCredentials.Builder createDefaultBuilder() throws IOExcept
167160
}
168161

169162
private TestEnvironmentProvider testEnvironmentProvider;
163+
170164
@Before
171165
public void setup() {
172166
testEnvironmentProvider = new TestEnvironmentProvider();
@@ -939,7 +933,6 @@ public void idTokenWithAudience_oauthFlow_targetAudienceDoesNotMatchAudClaim()
939933
tokenCredential.getIdToken().getJsonWebSignature().getPayload().getAudience());
940934
}
941935

942-
943936
@Test
944937
public void idTokenWithAudience_iamFlow_targetAudienceMatchesAudClaim() throws IOException {
945938

0 commit comments

Comments
 (0)