Forráskód Böngészése

Add support for priority in the Monolog bundle (https://github.com/symfony/monolog-bundle/pull/455) (#1797)

Co-authored-by: Roy <rdmartines@vcn.nl>
Roy 2 éve
szülő
commit
4356885fbb

+ 6 - 4
src/Monolog/Attribute/AsMonologProcessor.php

@@ -23,14 +23,16 @@ namespace Monolog\Attribute;
 class AsMonologProcessor
 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 function __construct(
         public readonly ?string $channel = null,
         public readonly ?string $channel = null,
         public readonly ?string $handler = null,
         public readonly ?string $handler = null,
-        public readonly ?string $method = null
+        public readonly ?string $method = null,
+        public readonly ?int $priority = null
     ) {
     ) {
     }
     }
 }
 }

+ 4 - 2
tests/Monolog/Attribute/AsMonologProcessorTest.php

@@ -20,14 +20,16 @@ final class AsMonologProcessorTest extends TestCase
 {
 {
     public function test(): void
     public function test(): void
     {
     {
-        $asMonologProcessor = new AsMonologProcessor('channel', 'handler', 'method');
+        $asMonologProcessor = new AsMonologProcessor('channel', 'handler', 'method', -10);
         $this->assertSame('channel', $asMonologProcessor->channel);
         $this->assertSame('channel', $asMonologProcessor->channel);
         $this->assertSame('handler', $asMonologProcessor->handler);
         $this->assertSame('handler', $asMonologProcessor->handler);
         $this->assertSame('method', $asMonologProcessor->method);
         $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->channel);
         $this->assertNull($asMonologProcessor->handler);
         $this->assertNull($asMonologProcessor->handler);
         $this->assertNull($asMonologProcessor->method);
         $this->assertNull($asMonologProcessor->method);
+        $this->assertNull($asMonologProcessor->priority);
     }
     }
 }
 }