Skip to content

Commit

Permalink
Add support for priority in the Monolog bundle (symfony/monolog-bundl…
Browse files Browse the repository at this point in the history
…e#455) (#1797)

Co-authored-by: Roy <rdmartines@vcn.nl>
  • Loading branch information
sudo-plz and Roy committed Jun 20, 2023
1 parent dc4bc7e commit 4356885
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/Monolog/Attribute/AsMonologProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@
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
) {
}
}
6 changes: 4 additions & 2 deletions tests/Monolog/Attribute/AsMonologProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 4356885

Please sign in to comment.