Beispiel #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;
        }
Beispiel #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="ignoreChar">A character which indicates the message should not be intercepted if it appears as the first character of a string written to the console. The character itself is not logged in that case.</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, char ignoreChar, 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.IgnoreChar    = ignoreChar;
            this.IsVerbose     = isVerbose;
        }
Beispiel #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="logFile">The log file to which to write messages.</param>
        public Monitor(string source, LogFileManager logFile)
        {
            // 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;
        }
Beispiel #4
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="exitTokenSource">Propagates notification that SMAPI should exit.</param>
        /// <param name="colorScheme">The console color scheme to use.</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, CancellationTokenSource exitTokenSource, MonitorColorScheme colorScheme, bool isVerbose)
        {
            // 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.ConsoleWriter      = new ColorfulConsoleWriter(Constants.Platform, colorScheme);
            this.ConsoleInterceptor = consoleInterceptor;
            this.ExitTokenSource    = exitTokenSource;
            this.IsVerbose          = isVerbose;
        }