Browse Source

Add logging objects and console colors

Bepis 6 years ago
parent
commit
8393cec211
1 changed files with 15 additions and 1 deletions
  1. 15 1
      BepInEx/Logger.cs

+ 15 - 1
BepInEx/Logger.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Runtime.CompilerServices;
+using BepInEx.ConsoleUtil;
 
 namespace BepInEx
 {
@@ -23,12 +24,25 @@ namespace BepInEx
         /// <summary>
         /// Logs an entry to the logger, and any listeners are notified of the entry.
         /// </summary>
+        /// <param name="entry">The text element of the log itself. Uses .ToString().</param>
+        /// <param name="show">Whether or not it should be dislpayed to the user.</param>
+        /// <param name="color">The color of the text to show in the console.</param>
+        public static void Log(object entry, bool show = false, ConsoleColor color = ConsoleColor.Gray)
+        {
+            Log(entry.ToString(), show, color);
+        }
+
+        /// <summary>
+        /// Logs an entry to the logger, and any listeners are notified of the entry.
+        /// </summary>
         /// <param name="entry">The text element of the log itself.</param>
         /// <param name="show">Whether or not it should be dislpayed to the user.</param>
-        public static void Log(string entry, bool show = false)
+        /// <param name="color">The color of the text to show in the console.</param>
+        public static void Log(string entry, bool show = false, ConsoleColor color = ConsoleColor.Gray)
         {
             UnityEngine.UnityLogWriter.WriteStringToUnityLog($"BEPIN - {entry}\r\n");
 
+            Kon.ForegroundColor = color;
             Console.WriteLine(entry);
 
             EntryLogged?.Invoke(entry, show);