From 4356885fbb49107d98d86dbe6068259674a8abd8 Mon Sep 17 00:00:00 2001 From: Roy Date: Tue, 20 Jun 2023 16:37:16 +0200 Subject: [PATCH] Add support for priority in the Monolog bundle (https://github.com/symfony/monolog-bundle/pull/455) (#1797) Co-authored-by: Roy --- src/Monolog/Attribute/AsMonologProcessor.php | 10 ++++++---- tests/Monolog/Attribute/AsMonologProcessorTest.php | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Monolog/Attribute/AsMonologProcessor.php b/src/Monolog/Attribute/AsMonologProcessor.php index f8b25021..c519e053 100644 --- a/src/Monolog/Attribute/AsMonologProcessor.php +++ b/src/Monolog/Attribute/AsMonologProcessor.php @@ -23,14 +23,16 @@ namespace Monolog\Attribute; class AsMonologProcessor { /** - * @param string|null $channel The logging channel the processor should be pushed to. - * @param string|null $handler The handler the processor should be pushed to. - * @param string|null $method The method that processes the records (if the attribute is used at the class level). + * @param string|null $channel The logging channel the processor should be pushed to. + * @param string|null $handler The handler the processor should be pushed to. + * @param string|null $method The method that processes the records (if the attribute is used at the class level). + * @param int|null $priority The priority of the processor so the order can be determined. */ public function __construct( public readonly ?string $channel = null, public readonly ?string $handler = null, - public readonly ?string $method = null + public readonly ?string $method = null, + public readonly ?int $priority = null ) { } } diff --git a/tests/Monolog/Attribute/AsMonologProcessorTest.php b/tests/Monolog/Attribute/AsMonologProcessorTest.php index b0af8f6f..8bee6683 100644 --- a/tests/Monolog/Attribute/AsMonologProcessorTest.php +++ b/tests/Monolog/Attribute/AsMonologProcessorTest.php @@ -20,14 +20,16 @@ final class AsMonologProcessorTest extends TestCase { public function test(): void { - $asMonologProcessor = new AsMonologProcessor('channel', 'handler', 'method'); + $asMonologProcessor = new AsMonologProcessor('channel', 'handler', 'method', -10); $this->assertSame('channel', $asMonologProcessor->channel); $this->assertSame('handler', $asMonologProcessor->handler); $this->assertSame('method', $asMonologProcessor->method); + $this->assertSame(-10, $asMonologProcessor->priority); - $asMonologProcessor = new AsMonologProcessor(null, null, null); + $asMonologProcessor = new AsMonologProcessor(null, null, null, null); $this->assertNull($asMonologProcessor->channel); $this->assertNull($asMonologProcessor->handler); $this->assertNull($asMonologProcessor->method); + $this->assertNull($asMonologProcessor->priority); } }