fix smapi-crash.txt being copied from default log even if --log-path is specified

This commit is contained in:
Jesse Plamondon-Willard 2017-05-21 17:58:17 -04:00
parent 9e7c77f1f4
commit bf3ed26a8b
3 changed files with 12 additions and 2 deletions

View File

@ -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).

View File

@ -13,6 +13,13 @@ namespace StardewModdingAPI.Framework.Logging
private readonly StreamWriter Stream;
/*********
** Accessors
*********/
/// <summary>The full path to the log file being written.</summary>
public string Path { get; }
/*********
** Public methods
*********/
@ -20,8 +27,10 @@ namespace StardewModdingAPI.Framework.Logging
/// <param name="path">The log file to write.</param>
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);

View File

@ -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)
{