| 148 |
lars |
1 |
<?php declare(strict_types=1);
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
* This file is part of the Monolog package.
|
|
|
5 |
*
|
|
|
6 |
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
|
|
7 |
*
|
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
|
|
9 |
* file that was distributed with this source code.
|
|
|
10 |
*/
|
|
|
11 |
|
|
|
12 |
namespace Monolog\Attribute;
|
|
|
13 |
|
|
|
14 |
/**
|
|
|
15 |
* A reusable attribute to help configure a class or a method as a processor.
|
|
|
16 |
*
|
|
|
17 |
* Using it offers no guarantee: it needs to be leveraged by a Monolog third-party consumer.
|
|
|
18 |
*
|
|
|
19 |
* Using it with the Monolog library only has no effect at all: processors should still be turned into a callable if
|
|
|
20 |
* needed and manually pushed to the loggers and to the processable handlers.
|
|
|
21 |
*/
|
|
|
22 |
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
|
|
23 |
class AsMonologProcessor
|
|
|
24 |
{
|
|
|
25 |
/** @var string|null */
|
|
|
26 |
public $channel = null;
|
|
|
27 |
/** @var string|null */
|
|
|
28 |
public $handler = null;
|
|
|
29 |
/** @var string|null */
|
|
|
30 |
public $method = null;
|
|
|
31 |
|
|
|
32 |
/**
|
|
|
33 |
* @param string|null $channel The logging channel the processor should be pushed to.
|
|
|
34 |
* @param string|null $handler The handler the processor should be pushed to.
|
|
|
35 |
* @param string|null $method The method that processes the records (if the attribute is used at the class level).
|
|
|
36 |
*/
|
|
|
37 |
public function __construct(
|
|
|
38 |
?string $channel = null,
|
|
|
39 |
?string $handler = null,
|
|
|
40 |
?string $method = null
|
|
|
41 |
) {
|
|
|
42 |
$this->channel = $channel;
|
|
|
43 |
$this->handler = $handler;
|
|
|
44 |
$this->method = $method;
|
|
|
45 |
}
|
|
|
46 |
}
|