/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ using System.Collections.Generic; namespace System.Management.Automation { /// /// Monad Logging in general is a two layer architecture. At the upper layer are the /// Msh Log Engine and Logging Api. At the lower layer is the Provider Interface /// and Log Providers. This architecture is adopted to achieve independency between /// Monad logging and logging details of different logging technology. /// /// This file implements the lower layer of the Monad Logging architecture. /// Upper layer of Msh Log architecture is implemented in MshLog.cs file. /// /// This class defines the provider interface to be implemented by each providers. /// /// Provider Interface. /// /// Corresponding to 5 categories of logging api interface, provider interface provides /// functions for logging /// a. EngineHealthEvent /// b. EngineLifecycleEvent /// c. CommandLifecycleEvent /// d. ProviderLifecycleEvent /// e. SettingsEvent /// /// internal abstract class LogProvider { /// /// constructor /// /// internal LogProvider() { } #region Provider api /// /// Provider interface function for logging health event /// /// /// /// /// /// internal abstract void LogEngineHealthEvent(LogContext logContext, int eventId, Exception exception, Dictionary additionalInfo); /// /// Provider interface function for logging engine lifecycle event /// /// /// /// /// internal abstract void LogEngineLifecycleEvent(LogContext logContext, EngineState newState, EngineState previousState); /// /// Provider interface function for logging command health event /// /// /// internal abstract void LogCommandHealthEvent(LogContext logContext, Exception exception); /// /// Provider interface function for logging command lifecycle event /// /// /// /// internal abstract void LogCommandLifecycleEvent(Func getLogContext, CommandState newState); /// /// Provider interface function for logging pipeline execution detail. /// /// /// internal abstract void LogPipelineExecutionDetailEvent(LogContext logContext, List pipelineExecutionDetail); /// /// Provider interface function for logging provider health event /// /// /// /// /// internal abstract void LogProviderHealthEvent(LogContext logContext, string providerName, Exception exception); /// /// Provider interface function for logging provider lifecycle event /// /// /// /// /// internal abstract void LogProviderLifecycleEvent(LogContext logContext, string providerName, ProviderState newState); /// /// Provider interface function for logging settings event /// /// /// /// /// /// internal abstract void LogSettingsEvent(LogContext logContext, string variableName, string value, string previousValue); /// /// True if the log provider needs to use logging variables /// /// internal virtual bool UseLoggingVariables() { return true; } #endregion } /// /// internal class DummyLogProvider : LogProvider { /// /// constructor /// /// internal DummyLogProvider() { } #region Provider api /// /// DummyLogProvider does nothing to Logging EngineHealthEvent /// /// /// /// /// /// internal override void LogEngineHealthEvent(LogContext logContext, int eventId, Exception exception, Dictionary additionalInfo) { } /// /// DummyLogProvider does nothing to Logging EngineLifecycleEvent /// /// /// /// /// internal override void LogEngineLifecycleEvent(LogContext logContext, EngineState newState, EngineState previousState) { } /// /// Provider interface function for logging command health event /// /// /// /// internal override void LogCommandHealthEvent(LogContext logContext, Exception exception) { } /// /// DummyLogProvider does nothing to Logging CommandLifecycleEvent /// /// /// /// internal override void LogCommandLifecycleEvent(Func getLogContext, CommandState newState) { } /// /// DummyLogProvider does nothing to Logging PipelineExecutionDetailEvent. /// /// /// internal override void LogPipelineExecutionDetailEvent(LogContext logContext, List pipelineExecutionDetail) { } /// /// Provider interface function for logging provider health event /// /// /// /// /// internal override void LogProviderHealthEvent(LogContext logContext, string providerName, Exception exception) { } /// /// DummyLogProvider does nothing to Logging ProviderLifecycleEvent /// /// /// /// /// internal override void LogProviderLifecycleEvent(LogContext logContext, string providerName, ProviderState newState) { } /// /// DummyLogProvider does nothing to Logging SettingsEvent /// /// /// /// /// /// internal override void LogSettingsEvent(LogContext logContext, string variableName, string value, string previousValue) { } #endregion } }