summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Framework/LogParsing/LogParser.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-02-24 16:52:38 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-02-24 16:52:38 -0500
commit691310d16e6873b83c55f62a59d5010dd8bb7e98 (patch)
treec62543dca097f7c914e27674222c34645f8498b8 /src/SMAPI.Web/Framework/LogParsing/LogParser.cs
parentd7696912e007a2b455a2fd5e1974924d2efe83b3 (diff)
downloadSMAPI-691310d16e6873b83c55f62a59d5010dd8bb7e98.tar.gz
SMAPI-691310d16e6873b83c55f62a59d5010dd8bb7e98.tar.bz2
SMAPI-691310d16e6873b83c55f62a59d5010dd8bb7e98.zip
add content pack support to log parser
Diffstat (limited to 'src/SMAPI.Web/Framework/LogParsing/LogParser.cs')
-rw-r--r--src/SMAPI.Web/Framework/LogParsing/LogParser.cs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs
index 1c3b5671..23a1baa4 100644
--- a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs
+++ b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs
@@ -31,6 +31,12 @@ namespace StardewModdingAPI.Web.Framework.LogParsing
/// <summary>A regex pattern matching an entry in SMAPI's mod list.</summary>
private readonly Regex ModListEntryPattern = new Regex(@"^ (?<name>.+) (?<version>.+) by (?<author>.+) \| (?<description>.+)$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
+ /// <summary>A regex pattern matching the start of SMAPI's content pack list.</summary>
+ private readonly Regex ContentPackListStartPattern = new Regex(@"^Loaded \d+ content packs:$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
+
+ /// <summary>A regex pattern matching an entry in SMAPI's content pack list.</summary>
+ private readonly Regex ContentPackListEntryPattern = new Regex(@"^ (?<name>.+) (?<version>.+) by (?<author>.+) \| for (?<for>.+?) \| (?<description>.+)$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
+
/*********
** Public methods
@@ -62,6 +68,7 @@ namespace StardewModdingAPI.Web.Framework.LogParsing
LogModInfo smapiMod = new LogModInfo { Name = "SMAPI", Author = "Pathoschild", Description = "" };
IDictionary<string, LogModInfo> mods = new Dictionary<string, LogModInfo>();
bool inModList = false;
+ bool inContentPackList = false;
foreach (LogMessage message in log.Messages)
{
// collect stats
@@ -79,6 +86,8 @@ namespace StardewModdingAPI.Web.Framework.LogParsing
// update flags
if (inModList && !this.ModListEntryPattern.IsMatch(message.Text))
inModList = false;
+ if (inContentPackList && !this.ContentPackListEntryPattern.IsMatch(message.Text))
+ inContentPackList = false;
// mod list
if (!inModList && message.Level == LogLevel.Info && this.ModListStartPattern.IsMatch(message.Text))
@@ -93,6 +102,20 @@ namespace StardewModdingAPI.Web.Framework.LogParsing
mods[name] = new LogModInfo { Name = name, Author = author, Version = version, Description = description };
}
+ // content pack list
+ else if (!inContentPackList && message.Level == LogLevel.Info && this.ContentPackListStartPattern.IsMatch(message.Text))
+ inContentPackList = true;
+ else if (inContentPackList)
+ {
+ Match match = this.ContentPackListEntryPattern.Match(message.Text);
+ string name = match.Groups["name"].Value;
+ string version = match.Groups["version"].Value;
+ string author = match.Groups["author"].Value;
+ 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 };
+ }
+
// platform info line
else if (message.Level == LogLevel.Info && this.InfoLinePattern.IsMatch(message.Text))
{