Skip to content

Commit 4356885

Browse files
sudo-plzRoy
andauthored
Add support for priority in the Monolog bundle (symfony/monolog-bundle#455) (#1797)
Co-authored-by: Roy <rdmartines@vcn.nl>
1 parent dc4bc7e commit 4356885

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/Monolog/Attribute/AsMonologProcessor.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@
2323
class AsMonologProcessor
2424
{
2525
/**
26-
* @param string|null $channel The logging channel the processor should be pushed to.
27-
* @param string|null $handler The handler the processor should be pushed to.
28-
* @param string|null $method The method that processes the records (if the attribute is used at the class level).
26+
* @param string|null $channel The logging channel the processor should be pushed to.
27+
* @param string|null $handler The handler the processor should be pushed to.
28+
* @param string|null $method The method that processes the records (if the attribute is used at the class level).
29+
* @param int|null $priority The priority of the processor so the order can be determined.
2930
*/
3031
public function __construct(
3132
public readonly ?string $channel = null,
3233
public readonly ?string $handler = null,
33-
public readonly ?string $method = null
34+
public readonly ?string $method = null,
35+
public readonly ?int $priority = null
3436
) {
3537
}
3638
}

tests/Monolog/Attribute/AsMonologProcessorTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@ final class AsMonologProcessorTest extends TestCase
2020
{
2121
public function test(): void
2222
{
23-
$asMonologProcessor = new AsMonologProcessor('channel', 'handler', 'method');
23+
$asMonologProcessor = new AsMonologProcessor('channel', 'handler', 'method', -10);
2424
$this->assertSame('channel', $asMonologProcessor->channel);
2525
$this->assertSame('handler', $asMonologProcessor->handler);
2626
$this->assertSame('method', $asMonologProcessor->method);
27+
$this->assertSame(-10, $asMonologProcessor->priority);
2728

28-
$asMonologProcessor = new AsMonologProcessor(null, null, null);
29+
$asMonologProcessor = new AsMonologProcessor(null, null, null, null);
2930
$this->assertNull($asMonologProcessor->channel);
3031
$this->assertNull($asMonologProcessor->handler);
3132
$this->assertNull($asMonologProcessor->method);
33+
$this->assertNull($asMonologProcessor->priority);
3234
}
3335
}

0 commit comments

Comments
 (0)