summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Framework/LogParsing
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-03-17 21:55:38 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-03-17 21:55:38 -0400
commit013255d89e1a802e05f9fd61a16701ca73fa4411 (patch)
tree684714b18faba6d4413a106f885bcba18a2e5edb /src/SMAPI.Web/Framework/LogParsing
parent10c7192bb9f06ff96b9b98a812d9f72a8d77ac76 (diff)
parent4a494c67bdfe2c07ef5c49c55541a0f6e29627cf (diff)
downloadSMAPI-013255d89e1a802e05f9fd61a16701ca73fa4411.tar.gz
SMAPI-013255d89e1a802e05f9fd61a16701ca73fa4411.tar.bz2
SMAPI-013255d89e1a802e05f9fd61a16701ca73fa4411.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI.Web/Framework/LogParsing')
-rw-r--r--src/SMAPI.Web/Framework/LogParsing/LogParser.cs18
-rw-r--r--src/SMAPI.Web/Framework/LogParsing/Models/LogMessage.cs6
-rw-r--r--src/SMAPI.Web/Framework/LogParsing/Models/LogSection.cs15
3 files changed, 39 insertions, 0 deletions
diff --git a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs
index fdc19404..3f33c0c1 100644
--- a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs
+++ b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs
@@ -119,7 +119,11 @@ namespace StardewModdingAPI.Web.Framework.LogParsing
// mod list
if (!inModList && message.Level == LogLevel.Info && this.ModListStartPattern.IsMatch(message.Text))
+ {
inModList = true;
+ message.IsStartOfSection = true;
+ message.Section = LogSection.ModsList;
+ }
else if (inModList)
{
Match match = this.ModListEntryPattern.Match(message.Text);
@@ -128,11 +132,17 @@ namespace StardewModdingAPI.Web.Framework.LogParsing
string author = match.Groups["author"].Value;
string description = match.Groups["description"].Value;
mods[name] = new LogModInfo { Name = name, Author = author, Version = version, Description = description, Loaded = true };
+
+ message.Section = LogSection.ModsList;
}
// content pack list
else if (!inContentPackList && message.Level == LogLevel.Info && this.ContentPackListStartPattern.IsMatch(message.Text))
+ {
inContentPackList = true;
+ message.IsStartOfSection = true;
+ message.Section = LogSection.ContentPackList;
+ }
else if (inContentPackList)
{
Match match = this.ContentPackListEntryPattern.Match(message.Text);
@@ -142,11 +152,17 @@ namespace StardewModdingAPI.Web.Framework.LogParsing
string description = match.Groups["description"].Value;
string forMod = match.Groups["for"].Value;
mods[name] = new LogModInfo { Name = name, Author = author, Version = version, Description = description, ContentPackFor = forMod, Loaded = true };
+
+ message.Section = LogSection.ContentPackList;
}
// mod update list
else if (!inModUpdateList && message.Level == LogLevel.Alert && this.ModUpdateListStartPattern.IsMatch(message.Text))
+ {
inModUpdateList = true;
+ message.IsStartOfSection = true;
+ message.Section = LogSection.ModUpdateList;
+ }
else if (inModUpdateList)
{
Match match = this.ModUpdateListEntryPattern.Match(message.Text);
@@ -162,6 +178,8 @@ namespace StardewModdingAPI.Web.Framework.LogParsing
{
mods[name] = new LogModInfo { Name = name, UpdateVersion = version, UpdateLink = link, Loaded = false };
}
+
+ message.Section = LogSection.ModUpdateList;
}
else if (message.Level == LogLevel.Alert && this.SMAPIUpdatePattern.IsMatch(message.Text))
diff --git a/src/SMAPI.Web/Framework/LogParsing/Models/LogMessage.cs b/src/SMAPI.Web/Framework/LogParsing/Models/LogMessage.cs
index baeac83c..f7c99d02 100644
--- a/src/SMAPI.Web/Framework/LogParsing/Models/LogMessage.cs
+++ b/src/SMAPI.Web/Framework/LogParsing/Models/LogMessage.cs
@@ -20,5 +20,11 @@ namespace StardewModdingAPI.Web.Framework.LogParsing.Models
/// <summary>The number of times this message was repeated consecutively.</summary>
public int Repeated { get; set; }
+
+ /// <summary>The section that this log message belongs to.</summary>
+ public LogSection? Section { get; set; }
+
+ /// <summary>Whether this message is the first one of its section.</summary>
+ public bool IsStartOfSection { get; set; }
}
}
diff --git a/src/SMAPI.Web/Framework/LogParsing/Models/LogSection.cs b/src/SMAPI.Web/Framework/LogParsing/Models/LogSection.cs
new file mode 100644
index 00000000..218d546c
--- /dev/null
+++ b/src/SMAPI.Web/Framework/LogParsing/Models/LogSection.cs
@@ -0,0 +1,15 @@
+namespace StardewModdingAPI.Web.Framework.LogParsing.Models
+{
+ /// <summary>The different sections of a log.</summary>
+ public enum LogSection
+ {
+ /// <summary>The list of mods the user has.</summary>
+ ModsList,
+
+ /// <summary>The list of content packs the user has.</summary>
+ ContentPackList,
+
+ /// <summary>The list of mod updates SMAPI has found.</summary>
+ ModUpdateList
+ }
+}