diff options
author | Zoryn <Zoryn4163@users.noreply.github.com> | 2016-03-21 21:05:55 -0400 |
---|---|---|
committer | Zoryn <Zoryn4163@users.noreply.github.com> | 2016-03-21 21:05:55 -0400 |
commit | c880c31aa10d6314a8d9d71822b5e052fe9dfb8c (patch) | |
tree | 198e2e864a2371530735c2c4506d077a709422c4 /StardewModdingAPI | |
parent | a7f704bb63cdb018b31de267af71714f0a6fb4e0 (diff) | |
parent | 46d21e384e3075b5352e20733f31e61d929d561a (diff) | |
download | SMAPI-c880c31aa10d6314a8d9d71822b5e052fe9dfb8c.tar.gz SMAPI-c880c31aa10d6314a8d9d71822b5e052fe9dfb8c.tar.bz2 SMAPI-c880c31aa10d6314a8d9d71822b5e052fe9dfb8c.zip |
Merge pull request #43 from Zoryn4163/master
logging refactors
Diffstat (limited to 'StardewModdingAPI')
-rw-r--r-- | StardewModdingAPI/Log.cs | 23 | ||||
-rw-r--r-- | StardewModdingAPI/Program.cs | 3 |
2 files changed, 17 insertions, 9 deletions
diff --git a/StardewModdingAPI/Log.cs b/StardewModdingAPI/Log.cs index 2784b709..04b05b55 100644 --- a/StardewModdingAPI/Log.cs +++ b/StardewModdingAPI/Log.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using System.IO; using System.Threading; @@ -28,7 +29,7 @@ namespace StardewModdingAPI catch (Exception) { // TODO: not use general exception - Log.Error("Could not initialize LogStream - Logging is disabled"); + Error("Could not initialize LogStream - Logging is disabled"); } } @@ -36,11 +37,11 @@ namespace StardewModdingAPI /// Print provided parameters to the console/file as applicable /// </summary> /// <param name="message">Desired message</param> - /// <param name="suppressMessage">When true, writes to ONLY console and not the log file.</param> + /// <param name="disableLogging">When true, writes to ONLY console and not the log file.</param> /// <param name="values">Additional params to be added to the message</param> private static void PrintLog(object message, bool disableLogging, params object[] values) { - string logOutput = string.Format("[{0}] {1}", System.DateTime.Now.ToLongTimeString(), String.Format(message.ToString(), values)); + string logOutput = $"[{DateTime.Now.ToLongTimeString()}] {string.Format(message.ToString(), values)}"; Console.WriteLine(logOutput); if (_logStream != null && !disableLogging) @@ -58,7 +59,7 @@ namespace StardewModdingAPI public static void Success(object message, params object[] values) { Console.ForegroundColor = ConsoleColor.Green; - Log.PrintLog(message?.ToString(), false, values); + PrintLog(message?.ToString(), false, values); Console.ForegroundColor = ConsoleColor.Gray; } @@ -69,7 +70,9 @@ namespace StardewModdingAPI /// <param name="values"></param> public static void Verbose(object message, params object[] values) { - Log.PrintLog(message?.ToString(), false, values); + Console.ForegroundColor = ConsoleColor.Gray; + PrintLog(message?.ToString(), false, values); + Console.ForegroundColor = ConsoleColor.Gray; } /// <summary> @@ -80,7 +83,7 @@ namespace StardewModdingAPI public static void Comment(object message, params object[] values) { Console.ForegroundColor = ConsoleColor.Yellow; - Log.PrintLog(message?.ToString(), false, values); + PrintLog(message?.ToString(), false, values); Console.ForegroundColor = ConsoleColor.Gray; } @@ -91,7 +94,9 @@ namespace StardewModdingAPI /// <param name="values"></param> public static void Info(object message, params object[] values) { - Log.PrintLog(message.ToString(), true, values); + Console.ForegroundColor = ConsoleColor.Gray; + PrintLog(message?.ToString(), true, values); + Console.ForegroundColor = ConsoleColor.Gray; } /// <summary> @@ -102,7 +107,7 @@ namespace StardewModdingAPI public static void Error(object message, params object[] values) { Console.ForegroundColor = ConsoleColor.Red; - Log.PrintLog(message.ToString(), false, values); + PrintLog(message?.ToString(), false, values); Console.ForegroundColor = ConsoleColor.Gray; } @@ -127,7 +132,7 @@ namespace StardewModdingAPI public static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Console.WriteLine("An exception has been caught"); - File.WriteAllText(_logPath + "\\MODDED_ErrorLog.Log_" + Extensions.Random.Next(100000000, 999999999) + ".txt", e.ExceptionObject.ToString()); + File.WriteAllText(_logPath + "\\MODDED_ErrorLog.Log_" + DateTime.UtcNow.Ticks + ".txt", e.ExceptionObject.ToString()); } /// <summary> diff --git a/StardewModdingAPI/Program.cs b/StardewModdingAPI/Program.cs index 77ea5d07..e4cbe609 100644 --- a/StardewModdingAPI/Program.cs +++ b/StardewModdingAPI/Program.cs @@ -8,6 +8,7 @@ using StardewValley.Menus; using System;
using System.Collections.Generic;
using System.ComponentModel;
+using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
@@ -46,6 +47,8 @@ namespace StardewModdingAPI /// <param name="args"></param>
private static void Main(string[] args)
{
+ Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB");
+
try
{
ConfigureUI();
|