From bd77373e70345900e87f472c542076ae2500f7cc Mon Sep 17 00:00:00 2001 From: IhateTrains Date: Thu, 21 Nov 2024 01:31:43 +0100 Subject: [PATCH] Fix CS8602 warning in MessageSlicer (#689) --- .github/actions/build_frontend/entrypoint.sh | 2 +- Fronter.NET/Services/MessageSlicer.cs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/actions/build_frontend/entrypoint.sh b/.github/actions/build_frontend/entrypoint.sh index 15e93a66..015ab589 100644 --- a/.github/actions/build_frontend/entrypoint.sh +++ b/.github/actions/build_frontend/entrypoint.sh @@ -38,7 +38,7 @@ then if [ "$RUNNER_OS" = "macOS" ] then - brew uninstall python-packaging + brew uninstall --ignore-dependencies python-packaging fi PIP_BREAK_SYSTEM_PACKAGES=1 pip3 install -r requirements.txt diff --git a/Fronter.NET/Services/MessageSlicer.cs b/Fronter.NET/Services/MessageSlicer.cs index 36b61e1e..16657bbb 100644 --- a/Fronter.NET/Services/MessageSlicer.cs +++ b/Fronter.NET/Services/MessageSlicer.cs @@ -1,11 +1,13 @@ using Fronter.Models; using log4net; using log4net.Core; +using System; using System.Text.RegularExpressions; namespace Fronter.Services; public static partial class MessageSlicer { + private static readonly ILog logger = LogManager.GetLogger("Frontend"); private static readonly Regex dateTimeRegex = GetDateTimeRegex(); public static LogLine SliceMessage(string message) { @@ -38,10 +40,15 @@ public static LogLine SliceMessage(string message) { } private static Level GetLogLevel(string levelStr) { - if (levelStr == "WARNING") { + if (levelStr.Equals("WARNING", StringComparison.OrdinalIgnoreCase)) { levelStr = "WARN"; } var level = LogManager.GetRepository().LevelMap[levelStr]; + if (level == null) { + logger.Warn($"Unknown log level: {levelStr}"); + level = Level.Debug; + } + return level; }