Skip to content

Commit

Permalink
Warn about bad regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Keelhauled committed Oct 26, 2020
1 parent 4c10c25 commit 5ad2d14
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/UnityLogFilter/UnityLogFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@ public static void Finish()

if(File.Exists(FilterFile))
{
filters = File.ReadAllLines(FilterFile).Where(VerifyRegex).Select(x => new Regex(x)).ToList();
Logger.LogInfo($"Loaded {filters.Count} filter{(filters.Count == 1 ? "" : "")}");
foreach(var line in File.ReadAllLines(FilterFile))
{
if(VerifyRegex(line))
filters.Add(new Regex(line));
else
Logger.LogWarning($"'{line}' is not a valid regex pattern");
}

Logger.LogInfo($"Loaded {filters.Count} filter{(filters.Count == 1 ? "" : "s")}");
}
else
{
Expand Down

0 comments on commit 5ad2d14

Please sign in to comment.