From 9286095c2711a66555c618f1bef3b634856abfdc Mon Sep 17 00:00:00 2001 From: Daniel Morell Date: Fri, 10 Jan 2025 13:59:51 -0600 Subject: [PATCH 1/2] Changed the `Telemeter::getLevelFromPsrLevel()` method from private to public. --- src/Telemetry/Telemeter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Telemetry/Telemeter.php b/src/Telemetry/Telemeter.php index 2869fcea..f10107dd 100644 --- a/src/Telemetry/Telemeter.php +++ b/src/Telemetry/Telemeter.php @@ -70,7 +70,7 @@ private static function getTypeFromLevel(string $level): EventType * @param string $level The PSR-3 log level. * @return EventLevel */ - private static function getLevelFromPsrLevel(string $level): EventLevel + public static function getLevelFromPsrLevel(string $level): EventLevel { return match ($level) { Level::EMERGENCY, Level::ALERT, Level::CRITICAL => EventLevel::Critical, From 30c4623f9522d309b1964c10e6911e10bc384991 Mon Sep 17 00:00:00 2001 From: Daniel Morell Date: Fri, 10 Jan 2025 15:02:48 -0600 Subject: [PATCH 2/2] Added tests for `Telemeter::getLevelFromPsrLevel()`. --- tests/Telemetry/TelemeterTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/Telemetry/TelemeterTest.php b/tests/Telemetry/TelemeterTest.php index 784c51ad..b8319250 100644 --- a/tests/Telemetry/TelemeterTest.php +++ b/tests/Telemetry/TelemeterTest.php @@ -24,6 +24,18 @@ public function testMaxEventConstrains(): void self::assertSame(100, $telemeter->getMaxQueueSize()); } + public function testGetLevelFromPsrLevel(): void + { + self::assertSame(EventLevel::Critical, Telemeter::getLevelFromPsrLevel(Level::EMERGENCY)); + self::assertSame(EventLevel::Critical, Telemeter::getLevelFromPsrLevel(Level::ALERT)); + self::assertSame(EventLevel::Critical, Telemeter::getLevelFromPsrLevel(Level::CRITICAL)); + self::assertSame(EventLevel::Error, Telemeter::getLevelFromPsrLevel(Level::ERROR)); + self::assertSame(EventLevel::Warning, Telemeter::getLevelFromPsrLevel(Level::WARNING)); + self::assertSame(EventLevel::Info, Telemeter::getLevelFromPsrLevel(Level::NOTICE)); + self::assertSame(EventLevel::Info, Telemeter::getLevelFromPsrLevel(Level::INFO)); + self::assertSame(EventLevel::Debug, Telemeter::getLevelFromPsrLevel(Level::DEBUG)); + } + public function testScope(): void { $telemeter = new Telemeter();