From f0cea68e324e5d54cbd1453f89a9b27c97d6af47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tibor=20Mik=C3=B3czy?= Date: Wed, 7 Oct 2020 19:36:16 +0200 Subject: [PATCH] Returned tracy 2.7 support (#41) * Returned tracy 2.7 support * Removed typehint to be compatible with Tracy\Logger * Added test to access priority * Changed test - level_name should be info * Spaces > tabs --- composer.json | 2 +- src/Tracy/BlueScreenRenderer.php | 2 +- src/Tracy/MonologAdapter.php | 2 +- tests/KdybyTests/Monolog/MonologAdapterTest.phpt | 13 +++++++++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 9b84509..c7c08d7 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "nette/di": "^3.0", "kdyby/strict-objects": "^2.0", "monolog/monolog": "^2.0", - "tracy/tracy": "^3.0" + "tracy/tracy": "^2.7 || ^3.0" }, "require-dev": { "nette/application": "^3.0", diff --git a/src/Tracy/BlueScreenRenderer.php b/src/Tracy/BlueScreenRenderer.php index 808943e..415687a 100644 --- a/src/Tracy/BlueScreenRenderer.php +++ b/src/Tracy/BlueScreenRenderer.php @@ -36,7 +36,7 @@ public function renderToFile($exception, $file): string * @internal * @deprecated */ - public function log($message, string $priority = self::INFO): ?string + public function log($message, $priority = self::INFO): ?string { throw new \Kdyby\Monolog\Exception\NotSupportedException('This class is only for rendering exceptions'); } diff --git a/src/Tracy/MonologAdapter.php b/src/Tracy/MonologAdapter.php index 271e8a7..bb468f7 100644 --- a/src/Tracy/MonologAdapter.php +++ b/src/Tracy/MonologAdapter.php @@ -72,7 +72,7 @@ public function getExceptionFile(\Throwable $exception, string $level = self::EX return $this->blueScreenRenderer->getExceptionFile($exception); } - public function log($originalMessage, string $priority = self::INFO): ?string + public function log($originalMessage, $priority = self::INFO): ?string { $message = $this->formatMessage($originalMessage); $context = [ diff --git a/tests/KdybyTests/Monolog/MonologAdapterTest.phpt b/tests/KdybyTests/Monolog/MonologAdapterTest.phpt index 868371b..87ad285 100644 --- a/tests/KdybyTests/Monolog/MonologAdapterTest.phpt +++ b/tests/KdybyTests/Monolog/MonologAdapterTest.phpt @@ -92,6 +92,19 @@ class MonologAdapterTest extends \Tester\TestCase Assert::match('CLI%a%: %a%/MonologAdapterTest.phpt%a%', $record['context']['at']); } + public function testLogWithAccessPriority() + { + $this->adapter->log('test access message', MonologAdapter::ACCESS); + Assert::count(1, $this->testHandler->getRecords()); + + list($record) = $this->testHandler->getRecords(); + Assert::same('kdyby', $record['channel']); + Assert::same('test access message', $record['message']); + Assert::same('INFO', $record['level_name']); + Assert::same(MonologAdapter::ACCESS, $record['context']['priority']); + Assert::match('CLI%a%: %a%/MonologAdapterTest.phpt%a%', $record['context']['at']); + } + } (new MonologAdapterTest())->run();