1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace leocata\M1\InternalFunctionality; |
4
|
|
|
|
5
|
|
|
use Psr\Log\LoggerInterface; |
6
|
|
|
use Psr\Log\LogLevel; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Special class that will act as backup in case no logger is given. |
10
|
|
|
* |
11
|
|
|
* As the name implies, this class won't do anything except declare the methods so we can still call them in this API. |
12
|
|
|
*/ |
13
|
|
|
class DummyLogger implements LoggerInterface |
14
|
|
|
{ |
15
|
|
|
public function emergency($message, array $context = []): void |
16
|
|
|
{ |
17
|
|
|
$this->log(LogLevel::EMERGENCY, $message, $context); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function alert($message, array $context = []): void |
21
|
|
|
{ |
22
|
|
|
$this->log(LogLevel::ALERT, $message, $context); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function critical($message, array $context = []): void |
26
|
|
|
{ |
27
|
|
|
$this->log(LogLevel::CRITICAL, $message, $context); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function error($message, array $context = []): void |
31
|
|
|
{ |
32
|
|
|
$this->log(LogLevel::ERROR, $message, $context); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function warning($message, array $context = []): void |
36
|
|
|
{ |
37
|
|
|
$this->log(LogLevel::WARNING, $message, $context); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function notice($message, array $context = []): void |
41
|
|
|
{ |
42
|
|
|
$this->log(LogLevel::NOTICE, $message, $context); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function info($message, array $context = []): void |
46
|
|
|
{ |
47
|
|
|
$this->log(LogLevel::INFO, $message, $context); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function debug($message, array $context = []): void |
51
|
|
|
{ |
52
|
|
|
$this->log(LogLevel::DEBUG, $message, $context); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @SuppressWarnings("unused") |
57
|
|
|
* |
58
|
|
|
* @param mixed $level |
59
|
|
|
* @param string $message |
60
|
|
|
* @param array $context |
61
|
|
|
*/ |
62
|
|
|
public function log($level, $message, array $context = []): void |
63
|
|
|
{ |
64
|
|
|
$this->log(LogLevel::DEBUG, $message, $context); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|