diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-12-21 12:25:27 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-12-21 12:25:27 -0500 |
commit | 71284e7176c55f66754470b19fd74b5b1fda4964 (patch) | |
tree | 848a7ec8c99e0e1f8335fac41f9e417dc1c86e40 /src/SMAPI/Framework/Monitor.cs | |
parent | 85b947dced10f5398055af36b5fdb6b8d32a6a6b (diff) | |
parent | 872a1d5627f20faece618644db1ae4749e124741 (diff) | |
download | SMAPI-71284e7176c55f66754470b19fd74b5b1fda4964.tar.gz SMAPI-71284e7176c55f66754470b19fd74b5b1fda4964.tar.bz2 SMAPI-71284e7176c55f66754470b19fd74b5b1fda4964.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Framework/Monitor.cs')
-rw-r--r-- | src/SMAPI/Framework/Monitor.cs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/SMAPI/Framework/Monitor.cs b/src/SMAPI/Framework/Monitor.cs index 533420a5..04e67d68 100644 --- a/src/SMAPI/Framework/Monitor.cs +++ b/src/SMAPI/Framework/Monitor.cs @@ -30,6 +30,9 @@ namespace StardewModdingAPI.Framework /// <summary>A cache of messages that should only be logged once.</summary> private readonly HashSet<string> LogOnceCache = new HashSet<string>(); + /// <summary>Get the screen ID that should be logged to distinguish between players in split-screen mode, if any.</summary> + private readonly Func<int?> GetScreenIdForLog; + /********* ** Accessors @@ -56,7 +59,8 @@ namespace StardewModdingAPI.Framework /// <param name="logFile">The log file to which to write messages.</param> /// <param name="colorConfig">The colors to use for text written to the SMAPI console.</param> /// <param name="isVerbose">Whether verbose logging is enabled. This enables more detailed diagnostic messages than are normally needed.</param> - public Monitor(string source, char ignoreChar, LogFileManager logFile, ColorSchemeConfig colorConfig, bool isVerbose) + /// <param name="getScreenIdForLog">Get the screen ID that should be logged to distinguish between players in split-screen mode, if any.</param> + public Monitor(string source, char ignoreChar, LogFileManager logFile, ColorSchemeConfig colorConfig, bool isVerbose, Func<int?> getScreenIdForLog) { // validate if (string.IsNullOrWhiteSpace(source)) @@ -68,6 +72,7 @@ namespace StardewModdingAPI.Framework this.ConsoleWriter = new ColorfulConsoleWriter(Constants.Platform, colorConfig); this.IgnoreChar = ignoreChar; this.IsVerbose = isVerbose; + this.GetScreenIdForLog = getScreenIdForLog; } /// <inheritdoc /> @@ -143,7 +148,9 @@ namespace StardewModdingAPI.Framework private string GenerateMessagePrefix(string source, ConsoleLogLevel level) { string levelStr = level.ToString().ToUpper().PadRight(Monitor.MaxLevelLength); - return $"[{DateTime.Now:HH:mm:ss} {levelStr} {source}]"; + int? playerIndex = this.GetScreenIdForLog(); + + return $"[{DateTime.Now:HH:mm:ss} {levelStr}{(playerIndex != null ? $" screen_{playerIndex}" : "")} {source}]"; } } } |