From cf3728562771b20b66c3f9307a72ae3b19b10bdf Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 27 Jun 2018 09:37:20 -0400 Subject: tweak log parser logic to handle new levels automatically --- src/SMAPI.Web/Views/LogParser/Index.cshtml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/SMAPI.Web/Views/LogParser') diff --git a/src/SMAPI.Web/Views/LogParser/Index.cshtml b/src/SMAPI.Web/Views/LogParser/Index.cshtml index 4d95901e..8151c502 100644 --- a/src/SMAPI.Web/Views/LogParser/Index.cshtml +++ b/src/SMAPI.Web/Views/LogParser/Index.cshtml @@ -5,6 +5,11 @@ @{ ViewData["Title"] = "SMAPI log parser"; IDictionary contentPacks = Model.GetContentPacksByMod(); + IDictionary defaultFilters = Enum + .GetValues(typeof(LogLevel)) + .Cast() + .ToDictionary(level => level.ToString().ToLower(), level => level != LogLevel.Trace); + JsonSerializerSettings noFormatting = new JsonSerializerSettings { Formatting = Formatting.None }; } @section Head { @@ -21,15 +26,8 @@ smapi.logParser({ logStarted: new Date(@Json.Serialize(Model.ParsedLog?.Timestamp)), showPopup: @Json.Serialize(Model.ParsedLog == null), - showMods: @Json.Serialize(Model.ParsedLog?.Mods?.Select(p => Model.GetSlug(p.Name)).Distinct().ToDictionary(slug => slug, slug => true), new JsonSerializerSettings { Formatting = Formatting.None }), - showLevels: { - @LogLevel.Trace.ToString().ToLower(): false, - @LogLevel.Debug.ToString().ToLower(): true, - @LogLevel.Info.ToString().ToLower(): true, - @LogLevel.Alert.ToString().ToLower(): true, - @LogLevel.Warn.ToString().ToLower(): true, - @LogLevel.Error.ToString().ToLower(): true - } + showMods: @Json.Serialize(Model.ParsedLog?.Mods?.Select(p => Model.GetSlug(p.Name)).Distinct().ToDictionary(slug => slug, slug => true), noFormatting), + showLevels: @Json.Serialize(defaultFilters, noFormatting) }, '@Model.SectionUrl'); }); -- cgit