tweak log parser logic to handle new levels automatically

This commit is contained in:
Jesse Plamondon-Willard 2018-06-27 09:37:20 -04:00
parent 9f7b4e0296
commit cf37285627
1 changed files with 7 additions and 9 deletions

View File

@ -5,6 +5,11 @@
@{
ViewData["Title"] = "SMAPI log parser";
IDictionary<string, LogModInfo[]> contentPacks = Model.GetContentPacksByMod();
IDictionary<string, bool> defaultFilters = Enum
.GetValues(typeof(LogLevel))
.Cast<LogLevel>()
.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');
});
</script>