private void Log(LogLevel msalLogLevel, string messageWithPii, string messageScrubbed) { if (msalLogLevel > Logger.Level) { return; } //format log message; string correlationId = CorrelationId.Equals(Guid.Empty) ? string.Empty : " - " + CorrelationId; var msalIdParameters = MsalIdHelper.GetMsalIdParameters(); string os = "N/A"; if (msalIdParameters.TryGetValue(MsalIdParameter.OS, out string osValue)) { os = osValue; } bool messageWithPiiExists = !string.IsNullOrWhiteSpace(messageWithPii); // If we have a message with PII, and PII logging is enabled, use the PII message, else use the scrubbed message. bool isLoggingPii = messageWithPiiExists && Logger.PiiLoggingEnabled; string messageToLog = isLoggingPii ? messageWithPii : messageScrubbed; string log = string.Format(CultureInfo.InvariantCulture, "{0} MSAL {1} {2} {3} [{4}{5}]{6} {7}", isLoggingPii ? "(True)" : "(False)", MsalIdHelper.GetMsalVersion(), msalIdParameters[MsalIdParameter.Product], os, DateTime.UtcNow, correlationId, Component, messageToLog); if (Logger.DefaultLoggingEnabled) { switch (Logger.Level) { case LogLevel.Error: _platformLogger.Error(log); break; case LogLevel.Warning: _platformLogger.Warning(log); break; case LogLevel.Info: _platformLogger.Information(log); break; case LogLevel.Verbose: _platformLogger.Verbose(log); break; } } ExecuteCallback(msalLogLevel, log, isLoggingPii); }
public void Log(LogLevel logLevel, string messageWithPii, string messageScrubbed) { if (IsLoggingEnabled(logLevel)) { var msalIdParameters = MsalIdHelper.GetMsalIdParameters(this); string os = "N/A"; if (msalIdParameters.TryGetValue(MsalIdParameter.OS, out string osValue)) { os = osValue; } bool messageWithPiiExists = !string.IsNullOrWhiteSpace(messageWithPii); // If we have a message with PII, and PII logging is enabled, use the PII message, else use the scrubbed message. bool isLoggingPii = messageWithPiiExists && PiiLoggingEnabled; string messageToLog = isLoggingPii ? messageWithPii : messageScrubbed; string log = string.Format(CultureInfo.InvariantCulture, "{0} MSAL {1} {2} {3} [{4}{5}]{6} {7}", isLoggingPii ? "(True)" : "(False)", MsalIdHelper.GetMsalVersion(), msalIdParameters[MsalIdParameter.Product], os, DateTime.UtcNow, _correlationId, ClientInformation, messageToLog); if (_isDefaultPlatformLoggingEnabled) { switch (logLevel) { case LogLevel.Error: _platformLogger.Error(log); break; case LogLevel.Warning: _platformLogger.Warning(log); break; case LogLevel.Info: _platformLogger.Information(log); break; case LogLevel.Verbose: _platformLogger.Verbose(log); break; } } _loggingCallback.Invoke(logLevel, log, isLoggingPii); } }
private void Log(LogLevel authLogLevel, string messageWithPii, string messageScrubbed) { if (_loggingCallback == null || authLogLevel >= _logLevel) { return; } bool messageWithPiiExists = !string.IsNullOrWhiteSpace(messageWithPii); // If we have a message with PII, and PII logging is enabled, use the PII message, else use the scrubbed message. bool isLoggingPii = messageWithPiiExists && PiiLoggingEnabled; string messageToLog = isLoggingPii ? messageWithPii : messageScrubbed; string log = $"{isLoggingPii} AUTH {DateTime.UtcNow} {ClientInformation} {messageToLog}"; if (_isDefaultPlatformLoggingEnabled) { switch (authLogLevel) { case LogLevel.Error: _platformLogger.Error(log); break; case LogLevel.Warning: _platformLogger.Warning(log); break; case LogLevel.Info: _platformLogger.Information(log); break; case LogLevel.Verbose: _platformLogger.Verbose(log); break; } } _loggingCallback.Invoke(authLogLevel, log, isLoggingPii); }