PluginProbe
UpdraftCentral Dashboard / 0.8.0
UpdraftCentral Dashboard v0.8.0
0.8.33 0.7.2 0.7.3 0.7.4 0.8.0 0.8.1 0.8.10 0.8.11 0.8.12 0.8.13 0.8.14 0.8.15 0.8.16 0.8.17 0.8.18 0.8.19 0.8.2 0.8.20 0.8.21 0.8.22 0.8.23 0.8.24 0.8.25 0.8.26 0.8.27 All 51 releases
updraftcentral / classes / class-updraft-logger.php

class-updraft-logger.php in UpdraftCentral Dashboard 0.8.0, at classes/class-updraft-logger.php

211 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) die('No direct access allowed');
4
5 require_once('class-updraft-logger-interface.php');
6 require_once('class-updraft-log-levels.php');
7 require_once('class-updraft-abstract-logger.php');
8 require_once('class-updraft-logger.php');
9
10 if (class_exists('Updraft_Logger')) return;
11
12 /**
13 * Class Updraft_Logger
14 */
15 class Updraft_Logger implements Updraft_Logger_Interface {
16
17 protected $_loggers = array();
18
19 /**
20 * Constructor method
21 *
22 * @param Updraft_Logger_Interface $logger
23 */
24 public function __construct(Updraft_Logger_Interface $logger = null) {
25 if (!empty($logger)) $this->_loggers = array($logger);
26 }
27
28 /**
29 * Add logger to loggers list
30 *
31 * @param Updraft_Logger_Interface $logger
32 */
33 public function add_logger(Updraft_Logger_Interface $logger) {
34 $this->_loggers[] = $logger;
35 }
36
37 /**
38 * Return list of loggers
39 *
40 * @return array
41 */
42 public function get_loggers() {
43 return $this->_loggers;
44 }
45
46 /**
47 * System is unusable.
48 *
49 * @param string $message
50 * @param array $context
51 * @return null
52 */
53 public function emergency($message, array $context = array()) {
54
55 if (empty($this->_loggers)) return false;
56
57 foreach ($this->_loggers as $logger) {
58 $logger->emergency($message, $context);
59 }
60
61 }
62
63 /**
64 * Action must be taken immediately.
65 *
66 * Example: Entire website down, database unavailable, etc. This should
67 * trigger the SMS alerts and wake you up.
68 *
69 * @param string $message
70 * @param array $context
71 * @return null
72 */
73 public function alert($message, array $context = array()) {
74
75 if (empty($this->_loggers)) return false;
76
77 foreach ($this->_loggers as $logger) {
78 $logger->alert($message, $context);
79 }
80
81 }
82
83 /**
84 * Critical conditions.
85 *
86 * Example: Application component unavailable, unexpected exception.
87 *
88 * @param string $message
89 * @param array $context
90 * @return null
91 */
92 public function critical($message, array $context = array()) {
93
94 if (empty($this->_loggers)) return false;
95
96 foreach ($this->_loggers as $logger) {
97 $logger->critical($message, $context);
98 }
99
100 }
101
102 /**
103 * Runtime errors that do not require immediate action but should typically
104 * be logged and monitored.
105 *
106 * @param string $message
107 * @param array $context
108 * @return null
109 */
110 public function error($message, array $context = array()) {
111
112 if (empty($this->_loggers)) return false;
113
114 foreach ($this->_loggers as $logger) {
115 $logger->error($message, $context);
116 }
117
118 }
119
120 /**
121 * Exceptional occurrences that are not errors.
122 *
123 * Example: Use of deprecated APIs, poor use of an API, undesirable things
124 * that are not necessarily wrong.
125 *
126 * @param string $message
127 * @param array $context
128 * @return null
129 */
130 public function warning($message, array $context = array()) {
131
132 if (empty($this->_loggers)) return false;
133
134 foreach ($this->_loggers as $logger) {
135 $logger->warning($message, $context);
136 }
137
138 }
139
140 /**
141 * Normal but significant events.
142 *
143 * @param string $message
144 * @param array $context
145 * @return null
146 */
147 public function notice($message, array $context = array()) {
148
149 if (empty($this->_loggers)) return false;
150
151 foreach ($this->_loggers as $logger) {
152 $logger->notice($message, $context);
153 }
154
155 }
156
157 /**
158 * Interesting events.
159 *
160 * Example: User logs in, SQL logs.
161 *
162 * @param string $message
163 * @param array $context
164 * @return null
165 */
166 public function info($message, array $context = array()) {
167
168 if (empty($this->_loggers)) return false;
169
170 foreach ($this->_loggers as $logger) {
171 $logger->info($message, $context);
172 }
173
174 }
175
176 /**
177 * Detailed debug information.
178 *
179 * @param string $message
180 * @param array $context
181 * @return null
182 */
183 public function debug($message, array $context = array()) {
184
185 if (empty($this->_loggers)) return false;
186
187 foreach ($this->_loggers as &$logger) {
188 $logger->debug($message, $context);
189 }
190
191 }
192
193 /**
194 * Logs with an arbitrary level.
195 *
196 * @param mixed $level
197 * @param string $message
198 * @param array $context
199 * @return null
200 */
201 public function log($level, $message, array $context = array()) {
202
203 if (empty($this->_loggers)) return false;
204
205 foreach ($this->_loggers as $logger) {
206 $logger->log($level, $message, $context);
207 }
208
209 }
210 }
211