internal static void LogProviderHealthEvent( ExecutionContext executionContext, string providerName, Exception exception, Severity severity) { using (MshLog._trace.TraceMethod()) { if (executionContext == null) { MshLog._trace.NewArgumentNullException(nameof(executionContext)); } else if (exception == null) { MshLog._trace.NewArgumentNullException(nameof(exception)); } else { if (!MshLog.NeedToLogProviderHealthEvent(executionContext)) { return; } InvocationInfo invocationInfo = (InvocationInfo)null; if (exception is IContainsErrorRecord containsErrorRecord && containsErrorRecord.ErrorRecord != null) { invocationInfo = containsErrorRecord.ErrorRecord.InvocationInfo; } MshLog.GetLogProvider(executionContext).LogProviderHealthEvent(MshLog.GetLogContext(executionContext, invocationInfo, severity), providerName, exception); } } }