1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace VPA\Logger; |
4
|
|
|
|
5
|
|
|
use Psr\Log\AbstractLogger; |
6
|
|
|
use Psr\Log\LogLevel; |
7
|
|
|
use \Stringable; |
|
|
|
|
8
|
|
|
|
9
|
|
|
class BaseLogger extends AbstractLogger |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Emergency situation |
13
|
|
|
* |
14
|
|
|
* @param string | Stringable $message |
15
|
|
|
* @param array $context |
16
|
|
|
* @return void |
17
|
|
|
*/ |
18
|
2 |
|
public function emergency(string | Stringable $message, array $context = []): void |
19
|
|
|
{ |
20
|
2 |
|
$this->log(LogLevel::EMERGENCY, $message, $context); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Action must be taken immediately. |
25
|
|
|
* |
26
|
|
|
* @param string | Stringable $message |
27
|
|
|
* @param array $context |
28
|
|
|
* @return void |
29
|
|
|
*/ |
30
|
2 |
|
public function alert(string | Stringable $message, array $context = []): void |
31
|
|
|
{ |
32
|
2 |
|
$this->log(LogLevel::ALERT, $message, $context); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Critical conditions. |
37
|
|
|
* |
38
|
|
|
* @param string | Stringable $message |
39
|
|
|
* @param array $context |
40
|
|
|
* @return void |
41
|
|
|
*/ |
42
|
2 |
|
public function critical(string | Stringable $message, array $context = []): void |
43
|
|
|
{ |
44
|
2 |
|
$this->log(LogLevel::CRITICAL, $message, $context); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Runtime errors that do not require immediate action but should |
49
|
|
|
* be logged and monitored. |
50
|
|
|
* |
51
|
|
|
* @param string | Stringable $message |
52
|
|
|
* @param array $context |
53
|
|
|
* @return void |
54
|
|
|
*/ |
55
|
2 |
|
public function error(string | Stringable $message, array $context = []): void |
56
|
|
|
{ |
57
|
2 |
|
$this->log(LogLevel::ERROR, $message, $context); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Exceptional occurrences that are not errors. |
62
|
|
|
* |
63
|
|
|
* @param string | Stringable $message |
64
|
|
|
* @param array $context |
65
|
|
|
* @return void |
66
|
|
|
*/ |
67
|
2 |
|
public function warning(string | Stringable $message, array $context = []): void |
68
|
|
|
{ |
69
|
2 |
|
$this->log(LogLevel::WARNING, $message, $context); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Normal but significant events. |
74
|
|
|
* |
75
|
|
|
* @param string | Stringable $message |
76
|
|
|
* @param array $context |
77
|
|
|
* @return void |
78
|
|
|
*/ |
79
|
2 |
|
public function notice(string | Stringable $message, array $context = []): void |
80
|
|
|
{ |
81
|
2 |
|
$this->log(LogLevel::NOTICE, $message, $context); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Interesting events. |
86
|
|
|
* |
87
|
|
|
* @param string | Stringable $message |
88
|
|
|
* @param array $context |
89
|
|
|
* @return void |
90
|
|
|
*/ |
91
|
2 |
|
public function info(string | Stringable $message, array $context = []): void |
92
|
|
|
{ |
93
|
2 |
|
$this->log(LogLevel::INFO, $message, $context); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Detailed debug information. |
98
|
|
|
* |
99
|
|
|
* @param string | Stringable $message |
100
|
|
|
* @param array $context |
101
|
|
|
* @return void |
102
|
|
|
*/ |
103
|
3 |
|
public function debug(string | Stringable $message, array $context = []): void |
104
|
|
|
{ |
105
|
3 |
|
$this->log(LogLevel::DEBUG, $message, $context); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Interpolates context values into the message placeholders. |
110
|
|
|
* Taken from PSR-3's example implementation. |
111
|
|
|
* @param string | Stringable $message |
112
|
|
|
* @param array $context |
113
|
|
|
* @return string |
114
|
|
|
*/ |
115
|
18 |
|
protected function interpolate(string | Stringable $message, array $context = []): string |
116
|
|
|
{ |
117
|
|
|
// build a replacement array with braces around the context keys |
118
|
18 |
|
$replace = []; |
119
|
18 |
|
foreach ($context as $key => $value) { |
120
|
18 |
|
$replace['{' . $key . '}'] = $this->castValue($value); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
// interpolate replacement values into the message and return |
124
|
18 |
|
return strtr((string)$message, $replace); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
public function log(mixed $level, string | Stringable $message, array $context = []): void |
128
|
|
|
{ |
129
|
|
|
} |
130
|
|
|
|
131
|
9 |
|
protected function castValue(mixed $value): mixed |
132
|
|
|
{ |
133
|
9 |
|
return $value; |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths