summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Framework/LogParsing
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Web/Framework/LogParsing')
-rw-r--r--src/SMAPI.Web/Framework/LogParsing/LogMessageBuilder.cs8
-rw-r--r--src/SMAPI.Web/Framework/LogParsing/LogParser.cs4
-rw-r--r--src/SMAPI.Web/Framework/LogParsing/Models/LogMessage.cs3
3 files changed, 13 insertions, 2 deletions
diff --git a/src/SMAPI.Web/Framework/LogParsing/LogMessageBuilder.cs b/src/SMAPI.Web/Framework/LogParsing/LogMessageBuilder.cs
index 42e283a9..992876ef 100644
--- a/src/SMAPI.Web/Framework/LogParsing/LogMessageBuilder.cs
+++ b/src/SMAPI.Web/Framework/LogParsing/LogMessageBuilder.cs
@@ -16,6 +16,9 @@ namespace StardewModdingAPI.Web.Framework.LogParsing
/// <summary>The log level for the next log message.</summary>
public LogLevel Level { get; set; }
+ /// <summary>The screen ID in split-screen mode.</summary>
+ public int ScreenId { get; set; }
+
/// <summary>The mod name for the next log message.</summary>
public string Mod { get; set; }
@@ -36,10 +39,11 @@ namespace StardewModdingAPI.Web.Framework.LogParsing
/// <summary>Start accumulating values for a new log message.</summary>
/// <param name="time">The local time when the log was posted.</param>
/// <param name="level">The log level.</param>
+ /// <param name="screenId">The screen ID in split-screen mode.</param>
/// <param name="mod">The mod name.</param>
/// <param name="text">The initial log text.</param>
/// <exception cref="InvalidOperationException">A log message is already started; call <see cref="Clear"/> before starting a new message.</exception>
- public void Start(string time, LogLevel level, string mod, string text)
+ public void Start(string time, LogLevel level, int screenId, string mod, string text)
{
if (this.Started)
throw new InvalidOperationException("Can't start new message, previous log message isn't done yet.");
@@ -48,6 +52,7 @@ namespace StardewModdingAPI.Web.Framework.LogParsing
this.Time = time;
this.Level = level;
+ this.ScreenId = screenId;
this.Mod = mod;
this.Text.Append(text);
}
@@ -74,6 +79,7 @@ namespace StardewModdingAPI.Web.Framework.LogParsing
{
Time = this.Time,
Level = this.Level,
+ ScreenId = this.ScreenId,
Mod = this.Mod,
Text = this.Text.ToString()
};
diff --git a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs
index 227dcd89..f69d4b6f 100644
--- a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs
+++ b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs
@@ -14,7 +14,7 @@ namespace StardewModdingAPI.Web.Framework.LogParsing
** Fields
*********/
/// <summary>A regex pattern matching the start of a SMAPI message.</summary>
- private readonly Regex MessageHeaderPattern = new Regex(@"^\[(?<time>\d\d[:\.]\d\d[:\.]\d\d) (?<level>[a-z]+) +(?<modName>[^\]]+)\] ", RegexOptions.Compiled | RegexOptions.IgnoreCase);
+ private readonly Regex MessageHeaderPattern = new Regex(@"^\[(?<time>\d\d[:\.]\d\d[:\.]\d\d) (?<level>[a-z]+)(?: +screen_(?<screen>\d+))? +(?<modName>[^\]]+)\] ", RegexOptions.Compiled | RegexOptions.IgnoreCase);
/// <summary>A regex pattern matching SMAPI's initial platform info message.</summary>
private readonly Regex InfoLinePattern = new Regex(@"^SMAPI (?<apiVersion>.+) with Stardew Valley (?<gameVersion>.+) on (?<os>.+)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
@@ -304,9 +304,11 @@ namespace StardewModdingAPI.Web.Framework.LogParsing
builder.Clear();
}
+ var screenGroup = header.Groups["screen"];
builder.Start(
time: header.Groups["time"].Value,
level: Enum.Parse<LogLevel>(header.Groups["level"].Value, ignoreCase: true),
+ screenId: screenGroup.Success ? int.Parse(screenGroup.Value) : 0, // main player is always screen ID 0
mod: header.Groups["modName"].Value,
text: line.Substring(header.Length)
);
diff --git a/src/SMAPI.Web/Framework/LogParsing/Models/LogMessage.cs b/src/SMAPI.Web/Framework/LogParsing/Models/LogMessage.cs
index f7c99d02..1e08be78 100644
--- a/src/SMAPI.Web/Framework/LogParsing/Models/LogMessage.cs
+++ b/src/SMAPI.Web/Framework/LogParsing/Models/LogMessage.cs
@@ -12,6 +12,9 @@ namespace StardewModdingAPI.Web.Framework.LogParsing.Models
/// <summary>The log level.</summary>
public LogLevel Level { get; set; }
+ /// <summary>The screen ID in split-screen mode.</summary>
+ public int ScreenId { get; set; }
+
/// <summary>The mod name.</summary>
public string Mod { get; set; }