Skip to content

Commit f7c917f

Browse files
committed
adjust parsed log fields to support external tools
1 parent 5f7706c commit f7c917f

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

docs/release-notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Fixed some JSON files breaking page layout.
1111
* Improved log parser:
1212
* Mods which failed to load are now shown in the mod list (with 'failed to load' in the error column).
13+
* Added suggested fix if there's a newer SMAPI version available.
1314
* Reduced response times with a new analysis cache and client-side fetch.
1415
* Removed support for very old SMAPI logs.
1516
* You can now download a JSON representation of the parsed log (see the download link at the bottom of the log page).

src/SMAPI.Web/Framework/LogParsing/LogParser.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ public ParsedLog Parse(string? logText)
150150
mods[name] = entries = [];
151151
entries.Add(new LogModInfo(ModType.CodeMod, name: name, author: author, version: version, description: description, loaded: true));
152152

153+
log.TotalCodeMods++;
154+
153155
message.Section = LogSection.ModsList;
154156
}
155157

@@ -173,6 +175,8 @@ public ParsedLog Parse(string? logText)
173175
mods[name] = entries = [];
174176
entries.Add(new LogModInfo(ModType.ContentPack, name: name, author: author, version: version, description: description, contentPackFor: forMod, loaded: true));
175177

178+
log.TotalContentPacks++;
179+
176180
message.Section = LogSection.ContentPackList;
177181
}
178182

@@ -215,6 +219,7 @@ public ParsedLog Parse(string? logText)
215219
foreach (LogModInfo entry in entries)
216220
entry.SetUpdate(newVersion, link);
217221

222+
hasModUpdates = true;
218223
message.Section = LogSection.ModUpdateList;
219224
}
220225
else if (message.Level == LogLevel.Alert && this.SmapiUpdatePattern.IsMatch(message.Text))
@@ -224,6 +229,8 @@ public ParsedLog Parse(string? logText)
224229
string link = match.Groups["link"].Value;
225230

226231
smapiMod.SetUpdate(version, link);
232+
233+
hasApiUpdate = true;
227234
}
228235

229236
// platform info line
@@ -235,7 +242,6 @@ public ParsedLog Parse(string? logText)
235242
log.OperatingSystem = match.Groups["os"].Value;
236243

237244
smapiMod.OverrideVersion(log.ApiVersion);
238-
log.ApiVersionParsed = smapiMod.GetParsedVersion();
239245
}
240246

241247
// mod path line

src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ public class ParsedLog
3131
/// <summary>The SMAPI version.</summary>
3232
public string? ApiVersion { get; set; }
3333

34-
/// <summary>The parsed SMAPI version, if it's valid.</summary>
35-
public ISemanticVersion? ApiVersionParsed { get; set; }
36-
3734
/// <summary>The game version.</summary>
3835
public string? GameVersion { get; set; }
3936

@@ -55,6 +52,18 @@ public class ParsedLog
5552
/// <summary>The log messages.</summary>
5653
public LogMessage[] Messages { get; set; } = [];
5754

55+
/// <summary>The number of loaded non-content-pack mods.</summary>
56+
public int TotalCodeMods { get; set; }
57+
58+
/// <summary>The number of loaded content packs.</summary>
59+
public int TotalContentPacks { get; set; }
60+
61+
/// <summary>Whether update alerts were detected for SMAPI itself.</summary>
62+
public bool HasApiUpdate { get; set; }
63+
64+
/// <summary>Whether update alerts were detected for one or more installed mods.</summary>
65+
public bool HasModUpdates { get; set; }
66+
5867

5968
/*********
6069
** Public methods
@@ -74,13 +83,16 @@ public ParsedLog(ParsedLog log)
7483

7584
// log data
7685
this.ApiVersion = log.ApiVersion;
77-
this.ApiVersionParsed = log.ApiVersionParsed;
7886
this.GameVersion = log.GameVersion;
7987
this.OperatingSystem = log.OperatingSystem;
8088
this.GamePath = log.GamePath;
8189
this.ModPath = log.ModPath;
8290
this.Timestamp = log.Timestamp;
8391
this.Mods = log.Mods;
8492
this.Messages = log.Messages;
93+
this.TotalCodeMods = log.TotalCodeMods;
94+
this.TotalContentPacks = log.TotalContentPacks;
95+
this.HasApiUpdate = log.HasApiUpdate;
96+
this.HasModUpdates = log.HasModUpdates;
8597
}
8698
}

src/SMAPI.Web/Views/LogParser/Index.cshtml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,14 @@
232232
@* parsed log *@
233233
<div v-if="data.IsValid">
234234
@* suggested fixes *@
235-
<div v-if="hasOutdatedMods">
235+
<div v-if="data.HasApiUpdate || hasOutdatedMods">
236236
<h2>Suggested fixes</h2>
237237
<ul id="fix-list">
238-
<li>
238+
<li v-if="data.HasApiUpdate">
239+
You have an older version of SMAPI installed. Consider updating SMAPI to fix problems.
240+
</li>
241+
242+
<li v-if="hasOutdatedMods">
239243
Consider updating these mods to fix problems:
240244

241245
<table id="updates" class="table">

0 commit comments

Comments
 (0)