From f9823c2ed091df8c31c6d7338acd69e63f598537 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 14 Nov 2016 19:31:22 -0500 Subject: migrate deprecation manager to new logging (#168) --- .../Framework/DeprecationManager.cs | 23 +++++++++------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'src/StardewModdingAPI/Framework') diff --git a/src/StardewModdingAPI/Framework/DeprecationManager.cs b/src/StardewModdingAPI/Framework/DeprecationManager.cs index 2d25db09..20549b3f 100644 --- a/src/StardewModdingAPI/Framework/DeprecationManager.cs +++ b/src/StardewModdingAPI/Framework/DeprecationManager.cs @@ -13,24 +13,22 @@ namespace StardewModdingAPI.Framework /// The deprecations which have already been logged (as 'mod name::noun phrase::version'). private readonly HashSet LoggedDeprecations = new HashSet(StringComparer.InvariantCultureIgnoreCase); + /// Encapsulates monitoring and logging for a given module. + private readonly IMonitor Monitor; + /// Tracks the installed mods. private readonly ModRegistry ModRegistry; - /********* - ** Accessors - *********/ - /// Whether -level deprecation messages should be shown in the console. - public bool SendNoticesToConsole { get; set; } - - /********* ** Public methods *********/ /// Construct an instance. + /// Encapsulates monitoring and logging for a given module. /// Tracks the installed mods. - public DeprecationManager(ModRegistry modRegistry) + public DeprecationManager(IMonitor monitor, ModRegistry modRegistry) { + this.Monitor = monitor; this.ModRegistry = modRegistry; } @@ -68,18 +66,15 @@ namespace StardewModdingAPI.Framework switch (severity) { case DeprecationLevel.Notice: - if (this.SendNoticesToConsole) - Log.Debug($"[DEV] {message}"); - else - Log.LogToFile(message); + this.Monitor.Log(message, LogLevel.Trace); break; case DeprecationLevel.Info: - Log.Debug(message); + this.Monitor.Log(message, LogLevel.Info); break; case DeprecationLevel.PendingRemoval: - Log.Warning(message); + this.Monitor.Log(message, LogLevel.Warn); break; default: -- cgit