Пример #1
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="source">The name of the module which logs messages using this instance.</param>
        /// <param name="consoleManager">Manages access to the console output.</param>
        /// <param name="logFile">The log file to which to write messages.</param>
        /// <param name="exitTokenSource">Propagates notification that SMAPI should exit.</param>
        public Monitor(string source, ConsoleInterceptionManager consoleManager, LogFileManager logFile, CancellationTokenSource exitTokenSource)
        {
            // validate
            if (string.IsNullOrWhiteSpace(source))
            {
                throw new ArgumentException("The log source cannot be empty.");
            }

            // initialise
            this.Source          = source;
            this.LogFile         = logFile ?? throw new ArgumentNullException(nameof(logFile), "The log file manager cannot be null.");
            this.ConsoleManager  = consoleManager;
            this.ExitTokenSource = exitTokenSource;
        }
Пример #2
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="source">The name of the module which logs messages using this instance.</param>
        /// <param name="consoleInterceptor">Intercepts access to the console output.</param>
        /// <param name="logFile">The log file to which to write messages.</param>
        /// <param name="colorConfig">The colors to use for text written to the SMAPI console.</param>
        /// <param name="isVerbose">Whether verbose logging is enabled. This enables more detailed diagnostic messages than are normally needed.</param>
        public Monitor(string source, ConsoleInterceptionManager consoleInterceptor, LogFileManager logFile, ColorSchemeConfig colorConfig, bool isVerbose)
        {
            // validate
            if (string.IsNullOrWhiteSpace(source))
            {
                throw new ArgumentException("The log source cannot be empty.");
            }

            // initialize
            this.Source             = source;
            this.LogFile            = logFile ?? throw new ArgumentNullException(nameof(logFile), "The log file manager cannot be null.");
            this.ConsoleWriter      = new ColorfulConsoleWriter(Constants.Platform, colorConfig);
            this.ConsoleInterceptor = consoleInterceptor;
            this.IsVerbose          = isVerbose;
        }
Пример #3
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="source">The name of the module which logs messages using this instance.</param>
        /// <param name="consoleManager">Manages access to the console output.</param>
        /// <param name="logFile">The log file to which to write messages.</param>
        /// <param name="requestExitDelegate">A delegate which requests that SMAPI immediately exit the game.</param>
        public Monitor(string source, ConsoleInterceptionManager consoleManager, LogFileManager logFile, RequestExitDelegate requestExitDelegate)
        {
            // validate
            if (string.IsNullOrWhiteSpace(source))
            {
                throw new ArgumentException("The log source cannot be empty.");
            }
            if (logFile == null)
            {
                throw new ArgumentNullException(nameof(logFile), "The log file manager cannot be null.");
            }

            // initialise
            this.Source         = source;
            this.LogFile        = logFile;
            this.ConsoleManager = consoleManager;
        }