diff --git a/docs/release-notes.md b/docs/release-notes.md
index 67d043a1..73fa8ed1 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -12,7 +12,8 @@
* For modders:
* Added support for flipped and rotated map tiles (in collaboration with Platonymous).
* Added support for `.tmx` maps using zlib compression (thanks to Platonymous!).
- * Mods are no longer prevented from suppressing key presses in the chatbox. Use this power wisely.
+ * Added `this.Monitor.LogOnce` method.
+ * Mods are no longer prevented from suppressing key presses in the chatbox.
* For the web UI:
* Added option to upload files using a file picker.
diff --git a/src/SMAPI/Framework/Monitor.cs b/src/SMAPI/Framework/Monitor.cs
index 06cf1b46..f630c7fe 100644
--- a/src/SMAPI/Framework/Monitor.cs
+++ b/src/SMAPI/Framework/Monitor.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Linq;
using StardewModdingAPI.Framework.Logging;
using StardewModdingAPI.Internal.ConsoleWriting;
@@ -26,6 +27,9 @@ namespace StardewModdingAPI.Framework
/// The maximum length of the values.
private static readonly int MaxLevelLength = (from level in Enum.GetValues(typeof(LogLevel)).Cast() select level.ToString().Length).Max();
+ /// A cache of messages that should only be logged once.
+ private readonly HashSet LogOnceCache = new HashSet();
+
/*********
** Accessors
@@ -74,6 +78,15 @@ namespace StardewModdingAPI.Framework
this.LogImpl(this.Source, message, (ConsoleLogLevel)level);
}
+ /// Log a message for the player or developer, but only if it hasn't already been logged since the last game launch.
+ /// The message to log.
+ /// The log severity level.
+ public void LogOnce(string message, LogLevel level = LogLevel.Trace)
+ {
+ if (this.LogOnceCache.Add($"{message}|{level}"))
+ this.LogImpl(this.Source, message, (ConsoleLogLevel)level);
+ }
+
/// Log a message that only appears when is enabled.
/// The message to log.
public void VerboseLog(string message)
diff --git a/src/SMAPI/IMonitor.cs b/src/SMAPI/IMonitor.cs
index f2d110b8..c400a211 100644
--- a/src/SMAPI/IMonitor.cs
+++ b/src/SMAPI/IMonitor.cs
@@ -18,6 +18,11 @@ namespace StardewModdingAPI
/// The log severity level.
void Log(string message, LogLevel level = LogLevel.Trace);
+ /// Log a message for the player or developer, but only if it hasn't already been logged since the last game launch.
+ /// The message to log.
+ /// The log severity level.
+ void LogOnce(string message, LogLevel level = LogLevel.Trace);
+
/// Log a message that only appears when is enabled.
/// The message to log.
void VerboseLog(string message);