From f625a4e8f1e2f64ae9cd278d4d275a97cb034b38 Mon Sep 17 00:00:00 2001 From: Dome Pongmongkol <19558668+rpdome@users.noreply.github.com> Date: Fri, 25 Oct 2024 11:15:27 -0700 Subject: [PATCH] Clean up logs (#2521) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove unnecessary logs. Related: [Remove unneeded logs by rpdome · Pull Request #2974 · AzureAD/ad-accounts-for-android (github.com)](https://github.com/AzureAD/ad-accounts-for-android/pull/2974) --- .../common/internal/broker/BrokerActivity.java | 2 +- .../identity/common/java/authorities/Authority.java | 11 +++-------- .../azureactivedirectory/AzureActiveDirectory.java | 6 +++--- .../common/java/result/LocalAuthenticationResult.java | 2 +- .../identity/common/java/util/StringUtil.java | 4 ++-- .../identity/common/java/util/ported/ObjectUtils.java | 4 ++-- 6 files changed, 12 insertions(+), 17 deletions(-) diff --git a/common/src/main/java/com/microsoft/identity/common/internal/broker/BrokerActivity.java b/common/src/main/java/com/microsoft/identity/common/internal/broker/BrokerActivity.java index d65c5e6c3a..39efae172c 100644 --- a/common/src/main/java/com/microsoft/identity/common/internal/broker/BrokerActivity.java +++ b/common/src/main/java/com/microsoft/identity/common/internal/broker/BrokerActivity.java @@ -138,7 +138,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { Logger.info(methodTag, "Result received from Broker " + "Request code: " + requestCode - + " Result code: " + requestCode + + " Result code: " + resultCode ); mBrokerResultReceived = true; diff --git a/common4j/src/main/com/microsoft/identity/common/java/authorities/Authority.java b/common4j/src/main/com/microsoft/identity/common/java/authorities/Authority.java index 7d779ca2c3..1c4c79149c 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/authorities/Authority.java +++ b/common4j/src/main/com/microsoft/identity/common/java/authorities/Authority.java @@ -27,13 +27,13 @@ import com.microsoft.identity.common.java.WarningType; import com.microsoft.identity.common.java.exception.ClientException; import com.microsoft.identity.common.java.logging.Logger; +import com.microsoft.identity.common.java.nativeauth.authorities.NativeAuthCIAMAuthority; import com.microsoft.identity.common.java.providers.microsoft.azureactivedirectory.AzureActiveDirectory; import com.microsoft.identity.common.java.providers.microsoft.azureactivedirectory.AzureActiveDirectorySlice; import com.microsoft.identity.common.java.providers.oauth2.OAuth2Strategy; import com.microsoft.identity.common.java.providers.oauth2.OAuth2StrategyParameters; import com.microsoft.identity.common.java.util.CommonURIBuilder; import com.microsoft.identity.common.java.util.StringUtil; -import com.microsoft.identity.common.java.nativeauth.authorities.NativeAuthCIAMAuthority; import java.io.IOException; import java.net.MalformedURLException; @@ -305,14 +305,13 @@ public int hashCode() { private static void performCloudDiscovery() throws IOException, URISyntaxException { final String methodName = ":performCloudDiscovery"; - Logger.info( + Logger.verbose( TAG + methodName, "Performing cloud discovery..." ); synchronized (sLock) { - Logger.info(TAG + methodName, "Acquired lock."); if (!AzureActiveDirectory.isInitialized()) { - Logger.info(TAG + methodName, "Not initialized. Starting request."); + Logger.verbose(TAG + methodName, "Not initialized. Starting request."); AzureActiveDirectory.performCloudDiscovery(); Logger.info(TAG + methodName, "Loaded cloud metadata."); } @@ -389,10 +388,6 @@ public static KnownAuthorityResult getKnownAuthorityResult(Authority authority) boolean known = false; try { - Logger.info( - TAG + methodName, - "Performing cloud discovery" - ); performCloudDiscovery(); } catch (final IOException ex) { clientException = new ClientException( diff --git a/common4j/src/main/com/microsoft/identity/common/java/providers/microsoft/azureactivedirectory/AzureActiveDirectory.java b/common4j/src/main/com/microsoft/identity/common/java/providers/microsoft/azureactivedirectory/AzureActiveDirectory.java index 3a57aaf40f..0d5617d010 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/providers/microsoft/azureactivedirectory/AzureActiveDirectory.java +++ b/common4j/src/main/com/microsoft/identity/common/java/providers/microsoft/azureactivedirectory/AzureActiveDirectory.java @@ -201,13 +201,13 @@ public static synchronized void performCloudDiscovery() // until the app is killed. HttpCache.flush(); - Logger.info(TAG + methodName, "Parsing response."); - AzureActiveDirectoryInstanceResponse instanceResponse = + final AzureActiveDirectoryInstanceResponse instanceResponse = ObjectMapper.deserializeJsonStringToObject( response.getBody(), AzureActiveDirectoryInstanceResponse.class ); - Logger.info(TAG + methodName, "Discovered [" + + Logger.verbose(TAG + methodName, "Discovered [" + instanceResponse.getClouds().size() + "] clouds."); for (final AzureActiveDirectoryCloud cloud : instanceResponse.getClouds()) { diff --git a/common4j/src/main/com/microsoft/identity/common/java/result/LocalAuthenticationResult.java b/common4j/src/main/com/microsoft/identity/common/java/result/LocalAuthenticationResult.java index bea2ce716a..7ce96b274f 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/result/LocalAuthenticationResult.java +++ b/common4j/src/main/com/microsoft/identity/common/java/result/LocalAuthenticationResult.java @@ -84,7 +84,7 @@ private LocalAuthenticationResult(@NonNull final ICacheRecord cacheRecord, @NonN cacheRecord.getIdToken(); if (idTokenRecord != null) { mRawIdToken = idTokenRecord.getSecret(); - Logger.info(TAG, "Id Token type: " + + Logger.verbose(TAG, "Id Token type: " + idTokenRecord.getCredentialType()); } else if (cacheRecord.getV1IdToken() != null) { // For all AAD requests, we hit the V2 endpoint, so the id token returned will be of version 2.0 (V2 ) diff --git a/common4j/src/main/com/microsoft/identity/common/java/util/StringUtil.java b/common4j/src/main/com/microsoft/identity/common/java/util/StringUtil.java index 350f4f98fb..28e1a30292 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/util/StringUtil.java +++ b/common4j/src/main/com/microsoft/identity/common/java/util/StringUtil.java @@ -477,9 +477,9 @@ public static String join(final CharSequence separator, */ public static void throwIfArgumentIsNullOrEmpty(final @Nullable String argument, final @NonNull String argumentName, - final @NonNull String methodName) throws NullPointerException { + final @NonNull String methodTag) throws NullPointerException { if (isNullOrEmpty(argument)) { - Logger.error(TAG + methodName, argumentName + " is null or empty.", null); + Logger.error(methodTag, argumentName + " is null or empty.", null); throw new NullPointerException(argumentName + " is null or empty."); } } diff --git a/common4j/src/main/com/microsoft/identity/common/java/util/ported/ObjectUtils.java b/common4j/src/main/com/microsoft/identity/common/java/util/ported/ObjectUtils.java index 2f8a983174..3e23ddca72 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/util/ported/ObjectUtils.java +++ b/common4j/src/main/com/microsoft/identity/common/java/util/ported/ObjectUtils.java @@ -56,9 +56,9 @@ public static boolean equals(@Nullable final Object o1, @Nullable final Object o */ public static void throwIfArgumentIsNull(final @Nullable Object argument, final @NonNull String argumentName, - final @NonNull String methodName) throws NullPointerException { + final @NonNull String methodTag) throws NullPointerException { if (argument == null) { - Logger.error(TAG + methodName, argumentName + " is null.", null); + Logger.error(methodTag, argumentName + " is null.", null); throw new NullPointerException(argumentName + " is null."); } }