From bf3ed26a8b6480a12c7e62f483234d8c616fae28 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 21 May 2017 17:58:17 -0400 Subject: fix smapi-crash.txt being copied from default log even if --log-path is specified --- release-notes.md | 1 + src/StardewModdingAPI/Framework/Logging/LogFileManager.cs | 11 ++++++++++- src/StardewModdingAPI/Program.cs | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/release-notes.md b/release-notes.md index ec05d4c3..679699a3 100644 --- a/release-notes.md +++ b/release-notes.md @@ -20,6 +20,7 @@ For players: For modders: * You can now list mod dependencies in the `manifest.json`. SMAPI will make sure your dependencies are loaded before your mod, and will show a friendly error if a dependency is missing. +* Fixed `smapi-crash.txt` being copied from the default log even if a different path is specified with `--log-path`. ## 1.13.1 See [log](https://github.com/Pathoschild/SMAPI/compare/1.13...1.13.1). diff --git a/src/StardewModdingAPI/Framework/Logging/LogFileManager.cs b/src/StardewModdingAPI/Framework/Logging/LogFileManager.cs index 1f6ade1d..8cfe0527 100644 --- a/src/StardewModdingAPI/Framework/Logging/LogFileManager.cs +++ b/src/StardewModdingAPI/Framework/Logging/LogFileManager.cs @@ -13,6 +13,13 @@ namespace StardewModdingAPI.Framework.Logging private readonly StreamWriter Stream; + /********* + ** Accessors + *********/ + /// The full path to the log file being written. + public string Path { get; } + + /********* ** Public methods *********/ @@ -20,8 +27,10 @@ namespace StardewModdingAPI.Framework.Logging /// The log file to write. public LogFileManager(string path) { + this.Path = path; + // create log directory if needed - string logDir = Path.GetDirectoryName(path); + string logDir = System.IO.Path.GetDirectoryName(path); if (logDir == null) throw new ArgumentException($"The log path '{path}' is not valid."); Directory.CreateDirectory(logDir); diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs index 4df63456..4a4b2ca7 100644 --- a/src/StardewModdingAPI/Program.cs +++ b/src/StardewModdingAPI/Program.cs @@ -160,7 +160,7 @@ namespace StardewModdingAPI try { File.WriteAllText(Constants.FatalCrashMarker, string.Empty); - File.Copy(Constants.DefaultLogPath, Constants.FatalCrashLog, overwrite: true); + File.Copy(this.LogFile.Path, Constants.FatalCrashLog, overwrite: true); } catch (Exception ex) { -- cgit