summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/release-notes.md1
-rw-r--r--src/SMAPI/Program.cs17
2 files changed, 17 insertions, 1 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index a06fc0c4..ba0815b3 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -2,6 +2,7 @@
## 2.1 (upcoming)
* For players:
* Fixed compatibility check crashing for players with Stardew Valley 1.08.
+ * Fixed the game's test messages being shown in the console and log.
* For modders:
* Added support for public code in reflection API, to simplify mod integrations.
diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs
index fe306e24..ce547d9b 100644
--- a/src/SMAPI/Program.cs
+++ b/src/SMAPI/Program.cs
@@ -6,6 +6,7 @@ using System.Linq;
using System.Reflection;
using System.Runtime.ExceptionServices;
using System.Security;
+using System.Text.RegularExpressions;
using System.Threading;
#if SMAPI_FOR_WINDOWS
using System.Management;
@@ -77,6 +78,13 @@ namespace StardewModdingAPI
/// <summary>Whether the program has been disposed.</summary>
private bool IsDisposed;
+ /// <summary>Regex patterns which match console messages to suppress from the console and log.</summary>
+ private readonly Regex[] SuppressConsolePatterns =
+ {
+ new Regex(@"^TextBox\.Selected is now '(?:True|False)'\.$", RegexOptions.Compiled | RegexOptions.CultureInvariant),
+ new Regex(@"^(?:FRUIT )?TREE: IsClient:(?:True|False) randomOutput: \d+$", RegexOptions.Compiled | RegexOptions.CultureInvariant)
+ };
+
/*********
** Public methods
@@ -910,7 +918,14 @@ namespace StardewModdingAPI
/// <param name="message">The message to log.</param>
private void HandleConsoleMessage(IMonitor monitor, string message)
{
- LogLevel level = message.Contains("Exception") ? LogLevel.Error : LogLevel.Trace; // intercept potential exceptions
+ // detect exception
+ LogLevel level = message.Contains("Exception") ? LogLevel.Error : LogLevel.Trace;
+
+ // ignore suppressed message
+ if (level != LogLevel.Error && this.SuppressConsolePatterns.Any(p => p.IsMatch(message)))
+ return;
+
+ // forward to monitor
monitor.Log(message, level);
}