コード例 #1
0
        /// <summary>
        /// Logger Write Async
        /// </summary>
        /// <param name="loggerOutputType">Specifying where to write the message</param>
        /// <param name="message">The message you want to write</param>
        /// <param name="filePath">This field is only needed for LoggerOutputType.File, specifying file</param>
        public async Task WriteAsync <T>(LoggerOutputType loggerOutputType, T message, string filePath = "")
        {
            switch (loggerOutputType)
            {
            case LoggerOutputType.Console:
            {
                await Console.Out.WriteAsync(FormatMessage(message));

                break;
            }

            case LoggerOutputType.File:
            {
                await File.WriteAllTextAsync(filePath, FormatMessage(message));

                break;
            }

            case LoggerOutputType.DebugOutput:
            {
                Debug.WriteLine(FormatMessage(message));
                break;
            }
            }
        }
コード例 #2
0
        /// <summary>
        /// Logger Write
        /// </summary>
        /// <param name="loggerOutputType">Specifying where to write the message</param>
        /// <param name="message">The message you want to write</param>
        /// <param name="filePath">This field is only needed for LoggerOutputType.File, specifying file</param>
        public void Write <T>(LoggerOutputType loggerOutputType, T message, string filePath = "")
        {
            switch (loggerOutputType)
            {
            case LoggerOutputType.Console:
            {
                Console.Write(FormatMessage(message));
                break;
            }

            case LoggerOutputType.File:
            {
                File.WriteAllText(filePath, FormatMessage(message));
                break;
            }

            case LoggerOutputType.DebugOutput:
            {
                Debug.WriteLine(FormatMessage(message));
                break;
            }
            }
        }