|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Jellyfish\Log; |
|
4
|
|
|
|
|
5
|
|
|
use Monolog\Handler\HandlerInterface; |
|
6
|
|
|
use Monolog\Logger; |
|
7
|
|
|
|
|
8
|
|
|
class LogFacade implements LogFacadeInterface |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* @var \Jellyfish\Log\LogFactory |
|
12
|
|
|
*/ |
|
13
|
|
|
protected $logFactory; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @param \Jellyfish\Log\LogFactory $logFactory |
|
17
|
|
|
*/ |
|
18
|
|
|
public function __construct(LogFactory $logFactory) |
|
19
|
|
|
{ |
|
20
|
|
|
$this->logFactory = $logFactory; |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @param string $message |
|
25
|
|
|
* @param mixed[] $context |
|
26
|
|
|
* |
|
27
|
|
|
* @return \Jellyfish\Log\LogFacadeInterface |
|
28
|
|
|
*/ |
|
29
|
|
|
public function emergency(string $message, array $context = []): LogFacadeInterface |
|
30
|
|
|
{ |
|
31
|
|
|
$this->logFactory->getLogger()->emergency($message, $context); |
|
32
|
|
|
|
|
33
|
|
|
return $this; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @param string $message |
|
38
|
|
|
* @param mixed[] $context |
|
39
|
|
|
* |
|
40
|
|
|
* @return \Jellyfish\Log\LogFacadeInterface |
|
41
|
|
|
*/ |
|
42
|
|
|
public function alert(string $message, array $context = []): LogFacadeInterface |
|
43
|
|
|
{ |
|
44
|
|
|
$this->logFactory->getLogger()->alert($message, $context); |
|
45
|
|
|
|
|
46
|
|
|
return $this; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param string $message |
|
51
|
|
|
* @param mixed[] $context |
|
52
|
|
|
* |
|
53
|
|
|
* @return \Jellyfish\Log\LogFacadeInterface |
|
54
|
|
|
*/ |
|
55
|
|
|
public function critical(string $message, array $context = []): LogFacadeInterface |
|
56
|
|
|
{ |
|
57
|
|
|
$this->logFactory->getLogger()->critical($message, $context); |
|
58
|
|
|
|
|
59
|
|
|
return $this; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @param string $message |
|
64
|
|
|
* @param mixed[] $context |
|
65
|
|
|
* |
|
66
|
|
|
* @return \Jellyfish\Log\LogFacadeInterface |
|
67
|
|
|
*/ |
|
68
|
|
|
public function error(string $message, array $context = []): LogFacadeInterface |
|
69
|
|
|
{ |
|
70
|
|
|
$this->logFactory->getLogger()->error($message, $context); |
|
71
|
|
|
|
|
72
|
|
|
return $this; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @param string $message |
|
77
|
|
|
* @param mixed[] $context |
|
78
|
|
|
* |
|
79
|
|
|
* @return \Jellyfish\Log\LogFacadeInterface |
|
80
|
|
|
*/ |
|
81
|
|
|
public function warning(string $message, array $context = []): LogFacadeInterface |
|
82
|
|
|
{ |
|
83
|
|
|
$this->logFactory->getLogger()->warning($message, $context); |
|
84
|
|
|
|
|
85
|
|
|
return $this; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* @param string $message |
|
90
|
|
|
* @param mixed[] $context |
|
91
|
|
|
* |
|
92
|
|
|
* @return \Jellyfish\Log\LogFacadeInterface |
|
93
|
|
|
*/ |
|
94
|
|
|
public function notice(string $message, array $context = []): LogFacadeInterface |
|
95
|
|
|
{ |
|
96
|
|
|
$this->logFactory->getLogger()->notice($message, $context); |
|
97
|
|
|
|
|
98
|
|
|
return $this; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @param string $message |
|
103
|
|
|
* @param mixed[] $context |
|
104
|
|
|
* |
|
105
|
|
|
* @return \Jellyfish\Log\LogFacadeInterface |
|
106
|
|
|
*/ |
|
107
|
|
|
public function info(string $message, array $context = []): LogFacadeInterface |
|
108
|
|
|
{ |
|
109
|
|
|
$this->logFactory->getLogger()->info($message, $context); |
|
110
|
|
|
|
|
111
|
|
|
return $this; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @param string $message |
|
116
|
|
|
* @param mixed[] $context |
|
117
|
|
|
* |
|
118
|
|
|
* @return \Jellyfish\Log\LogFacadeInterface |
|
119
|
|
|
*/ |
|
120
|
|
|
public function debug(string $message, array $context = []): LogFacadeInterface |
|
121
|
|
|
{ |
|
122
|
|
|
$this->logFactory->getLogger()->debug($message, $context); |
|
123
|
|
|
|
|
124
|
|
|
return $this; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* @param string $level |
|
129
|
|
|
* @param string $message |
|
130
|
|
|
* @param array $context |
|
131
|
|
|
* |
|
132
|
|
|
* @return \Jellyfish\Log\LogFacadeInterface |
|
133
|
|
|
*/ |
|
134
|
|
|
public function log(string $level, string $message, array $context = []): LogFacadeInterface |
|
135
|
|
|
{ |
|
136
|
|
|
$this->logFactory->getLogger()->log($level, $message, $context); |
|
137
|
|
|
|
|
138
|
|
|
return $this; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @param \Monolog\Handler\HandlerInterface $handler |
|
143
|
|
|
* |
|
144
|
|
|
* @return \Jellyfish\Log\LogFacadeInterface |
|
145
|
|
|
*/ |
|
146
|
|
|
public function addHandler(HandlerInterface $handler): LogFacadeInterface |
|
147
|
|
|
{ |
|
148
|
|
|
$logger = $this->logFactory->getLogger(); |
|
149
|
|
|
|
|
150
|
|
|
if ($logger instanceof Logger) { |
|
151
|
|
|
$logger->pushHandler($handler); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
return $this; |
|
155
|
|
|
} |
|
156
|
|
|
} |
|
157
|
|
|
|