예제 #1
0
 internal static void LogEngineHealthEvent(
     ExecutionContext executionContext,
     int eventId,
     Exception exception,
     Severity severity,
     Dictionary <string, string> additionalInfo,
     EngineState newEngineState)
 {
     using (MshLog._trace.TraceMethod())
     {
         if (executionContext == null)
         {
             MshLog._trace.NewArgumentNullException(nameof(executionContext));
         }
         else if (exception == null)
         {
             MshLog._trace.NewArgumentNullException(nameof(exception));
         }
         else
         {
             if (!MshLog.NeedToLogEngineHealthEvent(executionContext))
             {
                 return;
             }
             InvocationInfo invocationInfo = (InvocationInfo)null;
             if (exception is IContainsErrorRecord containsErrorRecord && containsErrorRecord.ErrorRecord != null)
             {
                 invocationInfo = containsErrorRecord.ErrorRecord.InvocationInfo;
             }
             MshLog.GetLogProvider(executionContext).LogEngineHealthEvent(MshLog.GetLogContext(executionContext, invocationInfo, severity), eventId, exception, additionalInfo);
             if (newEngineState == EngineState.None)
             {
                 return;
             }
             MshLog.LogEngineLifecycleEvent(executionContext, newEngineState, invocationInfo);
         }
     }
 }