PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 4.7.0
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v4.7.0
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
← All changes | includes/class-updraft-logger.php +41 -35 3.2.20 → 4.7.0 View file →
@@ -13,16 +13,21 @@
13 13 * Class Updraft_Logger
14 14 */
15 15 class Updraft_Logger implements Updraft_Logger_Interface {
16 16
17 + /**
18 + * Array of loggers
19 + *
20 + * @var Updraft_Logger_Interface[]
21 + */
17 22 protected $_loggers = array();
18 23
19 24 /**
20 25 * Constructor method
21 26 *
22 - * @param Updraft_Logger_Interface $logger
27 + * @param Updraft_Logger_Interface|null $logger
23 28 */
24 - public function __construct(Updraft_Logger_Interface $logger = null) {
29 + public function __construct($logger = null) {
25 30 if (!empty($logger)) $this->_loggers = array($logger);
26 31 }
27 32
28 33 /**
@@ -36,19 +41,20 @@
36 41 $_instance = new self();
37 42 }
38 43 return $_instance;
39 44 }
40 -
45 +
41 46 /**
42 47 * Add logger to loggers list
43 48 *
44 49 * @param Updraft_Logger_Interface $logger
50 + * @return false|void
45 51 */
46 - public function add_logger(Updraft_Logger_Interface $logger) {
52 + public function add_logger($logger) {
47 53 $logger_id = $logger_class = get_class($logger);
48 54
49 55 // don't add logger if it doesn't support multiple loggers.
50 - if (!empty($this->_loggers) && array_key_exists($logger_id, $this->_loggers) && false == $logger->is_allow_multiple()) return false;
56 + if (!empty($this->_loggers) && array_key_exists($logger_id, $this->_loggers) && false === $logger->is_allow_multiple()) return false;
51 57
52 58 $index = 0;
53 59
54 60 // get free id key.
@@ -73,13 +79,13 @@
73 79 * System is unusable.
74 80 *
75 81 * @param string $message
76 82 * @param array $context
77 - * @return null
83 + * @return void
78 84 */
79 - public function emergency($message, array $context = array()) {
85 + public function emergency($message, $context = array()) {
80 86
81 - if (empty($this->_loggers)) return false;
87 + if (empty($this->_loggers)) return;
82 88
83 89 foreach ($this->_loggers as $logger) {
84 90 $logger->emergency($message, $context);
85 91 }
@@ -93,13 +99,13 @@
93 99 * trigger the SMS alerts and wake you up.
94 100 *
95 101 * @param string $message
96 102 * @param array $context
97 - * @return null
103 + * @return void
98 104 */
99 - public function alert($message, array $context = array()) {
105 + public function alert($message, $context = array()) {
100 106
101 - if (empty($this->_loggers)) return false;
107 + if (empty($this->_loggers)) return;
102 108
103 109 foreach ($this->_loggers as $logger) {
104 110 $logger->alert($message, $context);
105 111 }
@@ -112,13 +118,13 @@
112 118 * Example: Application component unavailable, unexpected exception.
113 119 *
114 120 * @param string $message
115 121 * @param array $context
116 - * @return null
122 + * @return void
117 123 */
118 - public function critical($message, array $context = array()) {
124 + public function critical($message, $context = array()) {
119 125
120 - if (empty($this->_loggers)) return false;
126 + if (empty($this->_loggers)) return;
121 127
122 128 foreach ($this->_loggers as $logger) {
123 129 $logger->critical($message, $context);
124 130 }
@@ -130,13 +136,13 @@
130 136 * be logged and monitored.
131 137 *
132 138 * @param string $message
133 139 * @param array $context
134 - * @return null
140 + * @return void
135 141 */
136 - public function error($message, array $context = array()) {
142 + public function error($message, $context = array()) {
137 143
138 - if (empty($this->_loggers)) return false;
144 + if (empty($this->_loggers)) return;
139 145
140 146 foreach ($this->_loggers as $logger) {
141 147 $logger->error($message, $context);
142 148 }
@@ -150,13 +156,13 @@
150 156 * that are not necessarily wrong.
151 157 *
152 158 * @param string $message
153 159 * @param array $context
154 - * @return null
160 + * @return void
155 161 */
156 - public function warning($message, array $context = array()) {
162 + public function warning($message, $context = array()) {
157 163
158 - if (empty($this->_loggers)) return false;
164 + if (empty($this->_loggers)) return;
159 165
160 166 foreach ($this->_loggers as $logger) {
161 167 $logger->warning($message, $context);
162 168 }
@@ -167,13 +173,13 @@
167 173 * Normal but significant events.
168 174 *
169 175 * @param string $message
170 176 * @param array $context
171 - * @return null
177 + * @return void
172 178 */
173 - public function notice($message, array $context = array()) {
179 + public function notice($message, $context = array()) {
174 180
175 - if (empty($this->_loggers)) return false;
181 + if (empty($this->_loggers)) return;
176 182
177 183 foreach ($this->_loggers as $logger) {
178 184 $logger->notice($message, $context);
179 185 }
@@ -186,13 +192,13 @@
186 192 * Example: User logs in, SQL logs.
187 193 *
188 194 * @param string $message
189 195 * @param array $context
190 - * @return null
196 + * @return void
191 197 */
192 - public function info($message, array $context = array()) {
198 + public function info($message, $context = array()) {
193 199
194 - if (empty($this->_loggers)) return false;
200 + if (empty($this->_loggers)) return;
195 201
196 202 foreach ($this->_loggers as $logger) {
197 203 $logger->info($message, $context);
198 204 }
@@ -203,13 +209,13 @@
203 209 * Detailed debug information.
204 210 *
205 211 * @param string $message
206 212 * @param array $context
207 - * @return null
213 + * @return void
208 214 */
209 - public function debug($message, array $context = array()) {
215 + public function debug($message, $context = array()) {
210 216
211 - if (empty($this->_loggers)) return false;
217 + if (empty($this->_loggers)) return;
212 218
213 219 foreach ($this->_loggers as &$logger) {
214 220 $logger->debug($message, $context);
215 221 }
@@ -218,16 +224,16 @@
218 224
219 225 /**
220 226 * Logs with an arbitrary level.
221 227 *
222 - * @param mixed $level
223 - * @param string $message
224 - * @param array $context
225 - * @return null
228 + * @param string $message
229 + * @param mixed $level
230 + * @param array $context
231 + * @return void
226 232 */
227 - public function log($level, $message, array $context = array()) {
233 + public function log($message, $level, $context = array()) {
228 234
229 - if (empty($this->_loggers)) return false;
235 + if (empty($this->_loggers)) return;
230 236
231 237 foreach ($this->_loggers as $logger) {
232 238 $logger->log($message, $level, $context);
233 239 }