diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-12-30 11:47:23 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-12-30 11:47:23 -0500 |
commit | a7d3930d88b3f3b73c8f614372fcb839b3b5c5ad (patch) | |
tree | 73f03bf2b2d4d2083b09eac8f7bccebec4f78355 /src/StardewModdingAPI/Program.cs | |
parent | 33293cda179bffe0dff3e8fe6be453797a3c5ec4 (diff) | |
download | SMAPI-a7d3930d88b3f3b73c8f614372fcb839b3b5c5ad.tar.gz SMAPI-a7d3930d88b3f3b73c8f614372fcb839b3b5c5ad.tar.bz2 SMAPI-a7d3930d88b3f3b73c8f614372fcb839b3b5c5ad.zip |
encapsulate repeated monitor construction
Diffstat (limited to 'src/StardewModdingAPI/Program.cs')
-rw-r--r-- | src/StardewModdingAPI/Program.cs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs index 090098ca..9cb84cf5 100644 --- a/src/StardewModdingAPI/Program.cs +++ b/src/StardewModdingAPI/Program.cs @@ -125,7 +125,7 @@ namespace StardewModdingAPI Program.Monitor.Log($"You configured SMAPI to not check for updates. Running an old version of SMAPI is not recommended. You can enable update checks by editing or deleting {Constants.ApiConfigPath}.", LogLevel.Warn); // initialise legacy log - Log.Monitor = new Monitor("legacy mod", Program.LogFile) { ShowTraceInConsole = Program.Settings.DeveloperMode }; + Log.Monitor = Program.GetSecondaryMonitor("legacy mod"); Log.ModRegistry = Program.ModRegistry; // hook into & launch the game @@ -183,7 +183,7 @@ namespace StardewModdingAPI internal static IMonitor GetLegacyMonitorForMod() { string modName = Program.ModRegistry.GetModFromStack() ?? "unknown"; - return new Monitor(modName, Program.LogFile); + return Program.GetSecondaryMonitor(modName); } @@ -518,7 +518,7 @@ namespace StardewModdingAPI // inject data mod.ModManifest = manifest; mod.Helper = helper; - mod.Monitor = new Monitor(manifest.Name, Program.LogFile) { ShowTraceInConsole = Program.Settings.DeveloperMode }; + mod.Monitor = Program.GetSecondaryMonitor(manifest.Name); mod.PathOnDisk = directory; // track mod @@ -590,5 +590,12 @@ namespace StardewModdingAPI Console.ReadKey(); Environment.Exit(0); } + + /// <summary>Get a monitor instance derived from SMAPI's current settings.</summary> + /// <param name="name">The name of the module which will log messages with this instance.</param> + private static Monitor GetSecondaryMonitor(string name) + { + return new Monitor(name, Program.LogFile) { ShowTraceInConsole = Program.Settings.DeveloperMode }; + } } } |