From 674618664a72679812c1b51065f725fec99aa86d Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 19 Feb 2018 19:32:27 -0500 Subject: add unvalidated update tick event for specialised use cases (#446) --- src/SMAPI/Framework/ModLoading/InstructionHandleResult.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/SMAPI/Framework/ModLoading/InstructionHandleResult.cs') diff --git a/src/SMAPI/Framework/ModLoading/InstructionHandleResult.cs b/src/SMAPI/Framework/ModLoading/InstructionHandleResult.cs index 0ae598fc..6a7e0519 100644 --- a/src/SMAPI/Framework/ModLoading/InstructionHandleResult.cs +++ b/src/SMAPI/Framework/ModLoading/InstructionHandleResult.cs @@ -1,3 +1,5 @@ +using StardewModdingAPI.Events; + namespace StardewModdingAPI.Framework.ModLoading { /// Indicates how an instruction was handled. @@ -19,6 +21,9 @@ namespace StardewModdingAPI.Framework.ModLoading DetectedSaveSerialiser, /// The instruction is compatible, but uses the dynamic keyword which won't work on Linux/Mac. - DetectedDynamic + DetectedDynamic, + + /// The instruction is compatible, but references which may impact stability. + DetectedUnvalidatedUpdateTick } } -- cgit From d7696912e007a2b455a2fd5e1974924d2efe83b3 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 24 Feb 2018 16:51:37 -0500 Subject: reimplement log parser with serverside parsing and vue.js frontend --- docs/release-notes.md | 6 + src/SMAPI.Web/Controllers/LogParserController.cs | 35 ++- .../Framework/LogParsing/LogParseException.cs | 15 + src/SMAPI.Web/Framework/LogParsing/LogParser.cs | 222 ++++++++++++++ .../Framework/LogParsing/Models/LogLevel.cs | 24 ++ .../Framework/LogParsing/Models/LogMessage.cs | 24 ++ .../Framework/LogParsing/Models/ModInfo.cs | 24 ++ .../Framework/LogParsing/Models/ParsedLog.cs | 47 +++ src/SMAPI.Web/ViewModels/LogParserModel.cs | 9 +- src/SMAPI.Web/Views/LogParser/Index.cshtml | 219 ++++++++------ src/SMAPI.Web/wwwroot/Content/css/log-parser.css | 325 ++++++++++----------- src/SMAPI.Web/wwwroot/Content/js/log-parser.js | 321 ++++++-------------- src/SMAPI.sln | 2 +- .../ModLoading/InstructionHandleResult.cs | 2 +- 14 files changed, 771 insertions(+), 504 deletions(-) create mode 100644 src/SMAPI.Web/Framework/LogParsing/LogParseException.cs create mode 100644 src/SMAPI.Web/Framework/LogParsing/LogParser.cs create mode 100644 src/SMAPI.Web/Framework/LogParsing/Models/LogLevel.cs create mode 100644 src/SMAPI.Web/Framework/LogParsing/Models/LogMessage.cs create mode 100644 src/SMAPI.Web/Framework/LogParsing/Models/ModInfo.cs create mode 100644 src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs (limited to 'src/SMAPI/Framework/ModLoading/InstructionHandleResult.cs') diff --git a/docs/release-notes.md b/docs/release-notes.md index 08f945e4..03b6dd77 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -20,8 +20,14 @@ * Fixed unhelpful error when a translation file has duplicate keys due to case-insensitivity. * Fixed some JSON field names being case-sensitive. +* For the [log parser][]: + * Significantly reduced download size when viewing files with repeated errors. + * Improved parse error handling. + * Fixed 'log started' field showing incorrect date. + * For SMAPI developers: * Overhauled mod DB format to be more concise, reduce the memory footprint, and support versioning/defaulting more fields. + * Reimplemented log parser with serverside parsing and vue.js on the frontend. ## 2.4 * For players: diff --git a/src/SMAPI.Web/Controllers/LogParserController.cs b/src/SMAPI.Web/Controllers/LogParserController.cs index 04a11a82..62547deb 100644 --- a/src/SMAPI.Web/Controllers/LogParserController.cs +++ b/src/SMAPI.Web/Controllers/LogParserController.cs @@ -8,6 +8,8 @@ using Microsoft.Extensions.Options; using StardewModdingAPI.Web.Framework; using StardewModdingAPI.Web.Framework.Clients.Pastebin; using StardewModdingAPI.Web.Framework.ConfigModels; +using StardewModdingAPI.Web.Framework.LogParsing; +using StardewModdingAPI.Web.Framework.LogParsing.Models; using StardewModdingAPI.Web.ViewModels; namespace StardewModdingAPI.Web.Controllers @@ -52,25 +54,23 @@ namespace StardewModdingAPI.Web.Controllers [HttpGet] [Route("log")] [Route("log/{id}")] - public ViewResult Index(string id = null) + public async Task Index(string id = null) { - return this.View("Index", new LogParserModel(this.Config.LogParserUrl, id)); + // fresh page + if (string.IsNullOrWhiteSpace(id)) + return this.View("Index", new LogParserModel(this.Config.LogParserUrl, id, null)); + + // log page + PasteInfo paste = await this.GetAsync(id); + ParsedLog log = paste.Success + ? new LogParser().Parse(paste.Content) + : new ParsedLog { IsValid = false, Error = "Pastebin error: " + paste.Error }; + return this.View("Index", new LogParserModel(this.Config.LogParserUrl, id, log)); } /*** ** JSON ***/ - /// Fetch raw text from Pastebin. - /// The Pastebin paste ID. - [HttpGet, Produces("application/json")] - [Route("log/fetch/{id}")] - public async Task GetAsync(string id) - { - PasteInfo response = await this.Pastebin.GetAsync(id); - response.Content = this.DecompressString(response.Content); - return response; - } - /// Save raw log data. /// The log content to save. [HttpPost, Produces("application/json"), AllowLargePosts] @@ -85,6 +85,15 @@ namespace StardewModdingAPI.Web.Controllers /********* ** Private methods *********/ + /// Fetch raw text from Pastebin. + /// The Pastebin paste ID. + private async Task GetAsync(string id) + { + PasteInfo response = await this.Pastebin.GetAsync(id); + response.Content = this.DecompressString(response.Content); + return response; + } + /// Compress a string. /// The text to compress. /// Derived from . diff --git a/src/SMAPI.Web/Framework/LogParsing/LogParseException.cs b/src/SMAPI.Web/Framework/LogParsing/LogParseException.cs new file mode 100644 index 00000000..5d4c8c08 --- /dev/null +++ b/src/SMAPI.Web/Framework/LogParsing/LogParseException.cs @@ -0,0 +1,15 @@ +using System; + +namespace StardewModdingAPI.Web.Framework.LogParsing +{ + /// An error while parsing the log file which doesn't require a stack trace to troubleshoot. + internal class LogParseException : Exception + { + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The user-friendly error message. + public LogParseException(string message) : base(message) { } + } +} diff --git a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs new file mode 100644 index 00000000..1c3b5671 --- /dev/null +++ b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs @@ -0,0 +1,222 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using StardewModdingAPI.Web.Framework.LogParsing.Models; + +namespace StardewModdingAPI.Web.Framework.LogParsing +{ + /// Parses SMAPI log files. + public class LogParser + { + /********* + ** Properties + *********/ + /// A regex pattern matching the start of a SMAPI message. + private readonly Regex MessageHeaderPattern = new Regex(@"^\[(?