Example #1
0
        /// <summary>
        /// Writes a line into the debug log.
        /// </summary>
        /// <param name="message">The message to log</param>
        /// <param name="indent">Indentation level</param>
        /// <param name="messageLevel">Error level of the message</param>
        public void WriteLine(string message = "", int indent = 0, DebugLogMessageErrorLevel messageLevel = DebugLogMessageErrorLevel.Info)
        {
            message     = (message ?? "").Trim();
            LastMessage = message;

            // Add information for warning/error debug level
            switch (messageLevel)
            {
            case DebugLogMessageErrorLevel.Error:
                Errors.Add(message);
                message = $"ERROR: {message}";
                break;

            case DebugLogMessageErrorLevel.Warning:
                Warnings.Add(message);
                message = $"WARNING: {message}";
                break;
            }

            // Add indenting
            message = new string(' ', Math.Max(0, indent * 2)) + message;

            // Write the message to the console...
            Console.WriteLine(message);

            // ...and to the log file
            WriteToFile(message);
        }
Example #2
0
 /// <summary>
 /// Writes a line into the debug log.
 /// </summary>
 /// <param name="message">The message to log</param>
 /// <param name="messageLevel">Error level of the message</param>
 public void WriteLine(string message, DebugLogMessageErrorLevel messageLevel)
 {
     WriteLine(message, 0, messageLevel);
 }