diff options
Diffstat (limited to 'src/SMAPI.Web/Framework/LogParsing')
-rw-r--r-- | src/SMAPI.Web/Framework/LogParsing/LogParser.cs | 11 | ||||
-rw-r--r-- | src/SMAPI.Web/Framework/LogParsing/Models/LogLevel.cs | 17 |
2 files changed, 18 insertions, 10 deletions
diff --git a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs index f49fb05c..013c6c47 100644 --- a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs +++ b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; -using StardewModdingAPI.Common; +using StardewModdingAPI.Toolkit; using StardewModdingAPI.Web.Framework.LogParsing.Models; namespace StardewModdingAPI.Web.Framework.LogParsing @@ -31,13 +31,13 @@ namespace StardewModdingAPI.Web.Framework.LogParsing /// <summary>A regex pattern matching an entry in SMAPI's mod list.</summary> /// <remarks>The author name and description are optional.</remarks> - private readonly Regex ModListEntryPattern = new Regex(@"^ (?<name>.+?) (?<version>" + SemanticVersionImpl.UnboundedVersionPattern + @")(?: by (?<author>[^\|]+))?(?: \| (?<description>.+))?$", RegexOptions.Compiled | RegexOptions.IgnoreCase); + private readonly Regex ModListEntryPattern = new Regex(@"^ (?<name>.+?) (?<version>" + SemanticVersion.UnboundedVersionPattern + @")(?: 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); + private readonly Regex ContentPackListEntryPattern = new Regex(@"^ (?<name>.+) (?<version>.+) by (?<author>.+) \| for (?<for>.+?)(?: \| (?<description>.+))?$", RegexOptions.Compiled | RegexOptions.IgnoreCase); /********* @@ -135,7 +135,10 @@ namespace StardewModdingAPI.Web.Framework.LogParsing { Match match = this.ModPathPattern.Match(message.Text); log.ModPath = match.Groups["path"].Value; - log.GamePath = new FileInfo(log.ModPath).Directory.FullName; + int lastDelimiterPos = log.ModPath.LastIndexOfAny(new char[] { '/', '\\' }); + log.GamePath = lastDelimiterPos >= 0 + ? log.ModPath.Substring(0, lastDelimiterPos) + : log.ModPath; } // log UTC timestamp line diff --git a/src/SMAPI.Web/Framework/LogParsing/Models/LogLevel.cs b/src/SMAPI.Web/Framework/LogParsing/Models/LogLevel.cs index 40d21bf8..759f15db 100644 --- a/src/SMAPI.Web/Framework/LogParsing/Models/LogLevel.cs +++ b/src/SMAPI.Web/Framework/LogParsing/Models/LogLevel.cs @@ -1,24 +1,29 @@ +using StardewModdingAPI.Internal.ConsoleWriting; + namespace StardewModdingAPI.Web.Framework.LogParsing.Models { /// <summary>The log severity levels.</summary> public enum LogLevel { /// <summary>Tracing info intended for developers.</summary> - Trace, + Trace = ConsoleLogLevel.Trace, /// <summary>Troubleshooting info that may be relevant to the player.</summary> - Debug, + Debug = ConsoleLogLevel.Debug, /// <summary>Info relevant to the player. This should be used judiciously.</summary> - Info, + Info = ConsoleLogLevel.Info, /// <summary>An issue the player should be aware of. This should be used rarely.</summary> - Warn, + Warn = ConsoleLogLevel.Warn, /// <summary>A message indicating something went wrong.</summary> - Error, + Error = ConsoleLogLevel.Error, /// <summary>Important information to highlight for the player when player action is needed (e.g. new version available). This should be used rarely to avoid alert fatigue.</summary> - Alert + Alert = ConsoleLogLevel.Alert, + + /// <summary>A critical issue that generally signals an immediate end to the application.</summary> + Critical = ConsoleLogLevel.Critical } } |