internal static void LogCommandHealthEvent( ExecutionContext executionContext, 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.NeedToLogCommandHealthEvent(executionContext)) { return; } InvocationInfo invocationInfo = (InvocationInfo)null; if (exception is IContainsErrorRecord containsErrorRecord && containsErrorRecord.ErrorRecord != null) { invocationInfo = containsErrorRecord.ErrorRecord.InvocationInfo; } MshLog.GetLogProvider(executionContext).LogCommandHealthEvent(MshLog.GetLogContext(executionContext, invocationInfo, severity), exception); } } }