From bd4f674f0fa82878ecaeea7ec4f36bbbc87706cf Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Wed, 10 Sep 2025 13:03:15 +0900 Subject: [PATCH] Add a noset level and add uppercase support to fromName() Noset is for unset status, which is different from unknown. Also allow upper case so we can use "OK" and "ERROR" in addition to "ok" and "error". --- .../CoreLibs/Logging/Logger/MessageLevel.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/www/lib/CoreLibs/Logging/Logger/MessageLevel.php b/www/lib/CoreLibs/Logging/Logger/MessageLevel.php index 60bb2717..ed0fd293 100644 --- a/www/lib/CoreLibs/Logging/Logger/MessageLevel.php +++ b/www/lib/CoreLibs/Logging/Logger/MessageLevel.php @@ -13,6 +13,7 @@ namespace CoreLibs\Logging\Logger; enum MessageLevel: int { + case noset = 0; case ok = 100; case success = 150; // special for file uploads case info = 200; @@ -30,14 +31,14 @@ enum MessageLevel: int public static function fromName(string $name): self { return match (strtolower($name)) { - 'ok' => self::ok, - 'success' => self::success, - 'info' => self::info, - 'notice' => self::notice, - 'warn', 'warning' => self::warn, - 'error' => self::error, - 'abort' => self::abort, - 'crash' => self::crash, + 'ok', 'OK' => self::ok, + 'success', 'SUCCESS' => self::success, + 'info', 'INFO' => self::info, + 'notice', 'NOTICE' => self::notice, + 'warn', 'warning', 'WARN', 'WARNING' => self::warn, + 'error', 'ERROR' => self::error, + 'abort', 'ABORT' => self::abort, + 'crash', 'CRASH' => self::crash, default => self::unknown, }; }