|
2 | 2 |
|
3 | 3 | namespace JustBetter\Sentry\Plugin;
|
4 | 4 |
|
5 |
| -use JustBetter\Sentry\Helper\Data; |
6 |
| -use JustBetter\Sentry\Model\SentryLog; |
7 |
| -use Magento\Framework\App\DeploymentConfig; |
| 5 | +use JustBetter\Sentry\Logger\Handler\Sentry; |
8 | 6 | use Magento\Framework\Logger\Monolog;
|
9 |
| -use Monolog\DateTimeImmutable; |
| 7 | +use Monolog\LogRecord; |
| 8 | +use Monolog\Processor\ProcessorInterface; |
10 | 9 |
|
11 | 10 | class MonologPlugin extends Monolog
|
12 | 11 | {
|
13 | 12 | /**
|
14 | 13 | * @psalm-param array<callable(array): array> $processors
|
15 | 14 | *
|
16 |
| - * @param string $name The logging channel, a simple descriptive name that is attached to all log records |
17 |
| - * @param Data $sentryHelper |
18 |
| - * @param SentryLog $sentryLog |
19 |
| - * @param DeploymentConfig $deploymentConfig |
20 |
| - * @param \Monolog\Handler\HandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, etc. |
21 |
| - * @param callable[] $processors Optional array of processors |
| 15 | + * @param string $name The logging channel, a simple descriptive name that is attached to all log records |
| 16 | + * @param Sentry $sentryHandler |
| 17 | + * @param \Monolog\Handler\HandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, etc. |
| 18 | + * @param callable[] $processors Optional array of processors |
| 19 | + * |
| 20 | + * @phpstan-param array<(callable(LogRecord|array): LogRecord|array)|ProcessorInterface> $processors |
22 | 21 | */
|
23 | 22 | public function __construct(
|
24 | 23 | $name,
|
25 |
| - protected Data $sentryHelper, |
26 |
| - protected SentryLog $sentryLog, |
27 |
| - protected DeploymentConfig $deploymentConfig, |
| 24 | + Sentry $sentryHandler, |
28 | 25 | array $handlers = [],
|
29 | 26 | array $processors = []
|
30 | 27 | ) {
|
31 |
| - parent::__construct($name, $handlers, $processors); |
32 |
| - } |
| 28 | + $handlers['sentry'] = $sentryHandler; |
33 | 29 |
|
34 |
| - /** |
35 |
| - * Adds a log record to Sentry. |
36 |
| - * |
37 |
| - * @param int $level The logging level |
38 |
| - * @param string $message The log message |
39 |
| - * @param array $context The log context |
40 |
| - * @param DateTimeImmutable $datetime Datetime of log |
41 |
| - * |
42 |
| - * @return bool Whether the record has been processed |
43 |
| - */ |
44 |
| - public function addRecord( |
45 |
| - int $level, |
46 |
| - string $message, |
47 |
| - array $context = [], |
48 |
| - DateTimeImmutable $datetime = null |
49 |
| - ): bool { |
50 |
| - if ($this->deploymentConfig->isAvailable() && $this->sentryHelper->isActive()) { |
51 |
| - $this->sentryLog->send($message, $level, $context); |
52 |
| - } |
53 |
| - |
54 |
| - // @phpstan-ignore argument.type |
55 |
| - return parent::addRecord($level, $message, $context, $datetime); |
| 30 | + parent::__construct($name, $handlers, $processors); |
56 | 31 | }
|
57 | 32 | }
|
0 commit comments