Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
XdebugLogger
n/a
0 / 0
n/a
0 / 0
4
n/a
0 / 0
 __construct
n/a
0 / 0
n/a
0 / 0
1
 logImpl
n/a
0 / 0
n/a
0 / 0
3
1<?php
2
3declare(strict_types=1);
4
5namespace PeServer\Core\Log;
6
7use PeServer\Core\Log\LoggerBase;
8use PeServer\Core\Log\LogOptions;
9
10/**
11 * XDebugロガー。
12 *
13 * @codeCoverageIgnore
14 */
15final class XdebugLogger extends LoggerBase
16{
17    public function __construct(Logging $logging, LogOptions $options)
18    {
19        parent::__construct($logging, $options);
20        $this->xdebug = function_exists('xdebug_is_debugger_active');
21    }
22
23    #region property
24
25    private readonly bool $xdebug;
26
27    #endregion
28
29    #region LoggerBase
30
31    final protected function logImpl(int $level, int $traceIndex, $message, ...$parameters): void
32    {
33        if (!$this->xdebug) {
34            return;
35        }
36
37        if (!\xdebug_is_debugger_active()) {
38            return;
39        }
40
41        $logMessage = $this->format($level, $traceIndex + 1, $message, ...$parameters);
42        \xdebug_notify($logMessage);
43    }
44
45    #endregion
46}