From 772eba92c0a1857525941412435723dbc9ea844a Mon Sep 17 00:00:00 2001 From: Avery-Dunn Date: Thu, 16 Mar 2023 11:44:44 -0700 Subject: [PATCH 1/2] Add APIs for toggling MSALRuntime's logging systems --- .../aad/msal4jbrokers/MsalRuntimeBroker.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/msal4j-brokers/src/main/java/com/microsoft/aad/msal4jbrokers/MsalRuntimeBroker.java b/msal4j-brokers/src/main/java/com/microsoft/aad/msal4jbrokers/MsalRuntimeBroker.java index 68000997..59c5a4a2 100644 --- a/msal4j-brokers/src/main/java/com/microsoft/aad/msal4jbrokers/MsalRuntimeBroker.java +++ b/msal4j-brokers/src/main/java/com/microsoft/aad/msal4jbrokers/MsalRuntimeBroker.java @@ -176,4 +176,37 @@ public boolean isBrokerAvailable() { return false; } } + + /** + * Toggles whether or not detailed MSALRuntime logs will appear in MSAL Java's normal logging framework. + * + * If enabled, you will see logs directly from MSALRuntime, containing verbose information relating to telemetry, API calls,successful/failed requests, and more. + * These logs will appear alongside MSAL Java's logs (with a message indicating they came from MSALRuntime), and will follow the same log level as MSAL Java's logs (info/debug/error/etc.). + * + * If disabled (default), MSAL Java will still produce some logs related to MSALRuntime, particularly in error messages, but will be much less verbose. + * + * @param enableLogging true to enable MSALRuntime logs, false to disable it + */ + public void toggleLogging(boolean enableLogging) { + try { + MsalRuntimeInterop.toggleMsalRuntimeLogging(enableLogging); + } catch (Exception ex) { + throw new MsalClientException(String.format("Error occurred when calling MSALRuntime logging API: %s", ex.getMessage()), AuthenticationErrorCode.MSALRUNTIME_INTEROP_ERROR); + } + } + + /** + * If enabled, Personal Identifiable Information (PII) can appear in logs and error messages produced by MSALRuntime. + * + * If disabled (default), PII will not be shown, and you will simply see "(PII)" or similar notes in places where PII data would have appeared. + * + * @param enablePII true to allow PII to appear in logs and error messages, false to disallow it + */ + public void togglePII(boolean enablePII) { + try { + MsalRuntimeInterop.toggleMsalRuntimePIILogging(enablePII); + } catch (Exception ex) { + throw new MsalClientException(String.format("Error occurred when calling MSALRuntime PII logging API: %s", ex.getMessage()), AuthenticationErrorCode.MSALRUNTIME_INTEROP_ERROR); + } + } } From 782de8d2075387741a552eb5b96484dcfdc4c6db Mon Sep 17 00:00:00 2001 From: Avery-Dunn Date: Tue, 9 May 2023 17:13:55 -0700 Subject: [PATCH 2/2] Rename logging methods to be more clear --- .../com/microsoft/aad/msal4jbrokers/MsalRuntimeBroker.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/msal4j-brokers/src/main/java/com/microsoft/aad/msal4jbrokers/MsalRuntimeBroker.java b/msal4j-brokers/src/main/java/com/microsoft/aad/msal4jbrokers/MsalRuntimeBroker.java index 59c5a4a2..82563ace 100644 --- a/msal4j-brokers/src/main/java/com/microsoft/aad/msal4jbrokers/MsalRuntimeBroker.java +++ b/msal4j-brokers/src/main/java/com/microsoft/aad/msal4jbrokers/MsalRuntimeBroker.java @@ -187,7 +187,7 @@ public boolean isBrokerAvailable() { * * @param enableLogging true to enable MSALRuntime logs, false to disable it */ - public void toggleLogging(boolean enableLogging) { + public void enableBrokerLogging(boolean enableLogging) { try { MsalRuntimeInterop.toggleMsalRuntimeLogging(enableLogging); } catch (Exception ex) { @@ -202,7 +202,7 @@ public void toggleLogging(boolean enableLogging) { * * @param enablePII true to allow PII to appear in logs and error messages, false to disallow it */ - public void togglePII(boolean enablePII) { + public void enableBrokerPIILogging(boolean enablePII) { try { MsalRuntimeInterop.toggleMsalRuntimePIILogging(enablePII); } catch (Exception ex) {