diff options
Diffstat (limited to 'src/SMAPI/Framework/DeprecationManager.cs')
-rw-r--r-- | src/SMAPI/Framework/DeprecationManager.cs | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/SMAPI/Framework/DeprecationManager.cs b/src/SMAPI/Framework/DeprecationManager.cs index 76c2f616..fcdf722e 100644 --- a/src/SMAPI/Framework/DeprecationManager.cs +++ b/src/SMAPI/Framework/DeprecationManager.cs @@ -62,7 +62,7 @@ namespace StardewModdingAPI.Framework return; // queue warning - this.QueuedWarnings.Add(new DeprecationWarning(source, nounPhrase, version, severity)); + this.QueuedWarnings.Add(new DeprecationWarning(source, nounPhrase, version, severity, Environment.StackTrace)); } /// <summary>Print any queued messages.</summary> @@ -78,27 +78,40 @@ namespace StardewModdingAPI.Framework ? $"{warning.ModName ?? "An unknown mod"} uses deprecated code (legacy events are deprecated since SMAPI {warning.Version})." : $"{warning.ModName ?? "An unknown mod"} uses deprecated code ({warning.NounPhrase} is deprecated since SMAPI {warning.Version})."; #endif - if (warning.ModName == null) - message += $"{Environment.NewLine}{Environment.StackTrace}"; - // log message + // get log level + LogLevel level; switch (warning.Level) { case DeprecationLevel.Notice: - this.Monitor.Log(message, LogLevel.Trace); + level = LogLevel.Trace; break; case DeprecationLevel.Info: - this.Monitor.Log(message, LogLevel.Debug); + level = LogLevel.Debug; break; case DeprecationLevel.PendingRemoval: - this.Monitor.Log(message, LogLevel.Warn); + level = LogLevel.Warn; break; default: throw new NotSupportedException($"Unknown deprecation level '{warning.Level}'."); } + + // log message + if (warning.ModName != null) + this.Monitor.Log(message, level); + else + { + if (level == LogLevel.Trace) + this.Monitor.Log($"{message}\n{warning.StackTrace}", level); + else + { + this.Monitor.Log(message, level); + this.Monitor.Log(warning.StackTrace); + } + } } this.QueuedWarnings.Clear(); } |