diff options
author | Zoryn Aaron <zoryn4163@gmail.com> | 2016-03-02 08:28:20 -0500 |
---|---|---|
committer | Zoryn Aaron <zoryn4163@gmail.com> | 2016-03-02 08:28:20 -0500 |
commit | 38bce3315841c66409e02844c86eb7a5e9295565 (patch) | |
tree | 401d2c02aa209254b12a09525708816bb2e32c4f /StardewModdingAPI | |
parent | c37d34a2707f54d766a832ffba2fb406397746c7 (diff) | |
download | SMAPI-38bce3315841c66409e02844c86eb7a5e9295565.tar.gz SMAPI-38bce3315841c66409e02844c86eb7a5e9295565.tar.bz2 SMAPI-38bce3315841c66409e02844c86eb7a5e9295565.zip |
fxies logging breaking?
Diffstat (limited to 'StardewModdingAPI')
-rw-r--r-- | StardewModdingAPI/Program.cs | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/StardewModdingAPI/Program.cs b/StardewModdingAPI/Program.cs index 01075370..4277bdce 100644 --- a/StardewModdingAPI/Program.cs +++ b/StardewModdingAPI/Program.cs @@ -49,8 +49,9 @@ namespace StardewModdingAPI public static Thread gameThread; public static Thread consoleInputThread; - public const string Version = "0.32 Alpha"; + public const string Version = "0.33 Alpha"; public const bool debug = false; + public static bool disableLogging { get; private set; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -101,7 +102,7 @@ namespace StardewModdingAPI try { - if (Directory.Exists(LogPath)) + if (!Directory.Exists(LogPath)) Directory.CreateDirectory(LogPath); } catch (Exception ex) @@ -113,7 +114,15 @@ namespace StardewModdingAPI Log(ExecutionPath, false); - LogStream = new StreamWriter(CurrentLog, false); + try + { + LogStream = new StreamWriter(CurrentLog, false); + } + catch (Exception ex) + { + disableLogging = true; + LogError("Could not initialize LogStream - Logging is disabled"); + } LogInfo("Initializing SDV Assembly..."); if (!File.Exists(ExecutionPath + "\\Stardew Valley.exe")) @@ -341,7 +350,8 @@ namespace StardewModdingAPI //System.Threading.Thread.Sleep(10); if (debug) { - SGame.CurrentLocation = SGame.ModLocations.First(x => x.name == newLocation.name); + Console.WriteLine(newLocation.name); + SGame.CurrentLocation = SGame.ModLocations.FirstOrDefault(x => x.name == newLocation.name); } //Game1.currentLocation = SGame.CurrentLocation; //LogInfo(((SGameLocation) newLocation).name); @@ -411,8 +421,12 @@ namespace StardewModdingAPI } string toLog = string.Format("[{0}] {1}", System.DateTime.Now.ToLongTimeString(), String.Format(o.ToString(), format)); Console.WriteLine(toLog); - LogStream.WriteLine(toLog); - LogStream.Flush(); + + if (!disableLogging) + { + LogStream.WriteLine(toLog); + LogStream.Flush(); + } } public static void LogColour(ConsoleColor c, object o, params object[] format) |