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0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / class-wc-logger.php
woocommerce / includes Last commit date
abstracts 8 years ago admin 8 years ago api 8 years ago cli 8 years ago customizer 8 years ago data-stores 8 years ago emails 8 years ago export 8 years ago gateways 8 years ago import 8 years ago interfaces 8 years ago legacy 8 years ago libraries 8 years ago log-handlers 8 years ago payment-tokens 8 years ago shipping 8 years ago shortcodes 8 years ago theme-support 8 years ago walkers 8 years ago widgets 8 years ago class-wc-ajax.php 8 years ago class-wc-api.php 8 years ago class-wc-auth.php 8 years ago class-wc-autoloader.php 8 years ago class-wc-background-emailer.php 8 years ago class-wc-background-updater.php 8 years ago class-wc-breadcrumb.php 8 years ago class-wc-cache-helper.php 8 years ago class-wc-cart-fees.php 8 years ago class-wc-cart-session.php 8 years ago class-wc-cart-totals.php 8 years ago class-wc-cart.php 8 years ago class-wc-checkout.php 8 years ago class-wc-cli.php 8 years ago class-wc-comments.php 8 years ago class-wc-countries.php 8 years ago class-wc-coupon.php 8 years ago class-wc-customer-download-log.php 8 years ago class-wc-customer-download.php 8 years ago class-wc-customer.php 8 years ago class-wc-data-exception.php 8 years ago class-wc-data-store.php 8 years ago class-wc-datetime.php 8 years ago class-wc-deprecated-action-hooks.php 8 years ago class-wc-deprecated-filter-hooks.php 8 years ago class-wc-discounts.php 8 years ago class-wc-download-handler.php 8 years ago class-wc-emails.php 8 years ago class-wc-embed.php 8 years ago class-wc-form-handler.php 8 years ago class-wc-frontend-scripts.php 8 years ago class-wc-geo-ip.php 8 years ago class-wc-geolite-integration.php 8 years ago class-wc-geolocation.php 8 years ago class-wc-https.php 8 years ago class-wc-install.php 8 years ago class-wc-integrations.php 8 years ago class-wc-log-levels.php 8 years ago class-wc-logger.php 8 years ago class-wc-meta-data.php 8 years ago class-wc-order-factory.php 8 years ago class-wc-order-item-coupon.php 8 years ago class-wc-order-item-fee.php 8 years ago class-wc-order-item-meta.php 8 years ago class-wc-order-item-product.php 8 years ago class-wc-order-item-shipping.php 8 years ago class-wc-order-item-tax.php 8 years ago class-wc-order-item.php 8 years ago class-wc-order-query.php 8 years ago class-wc-order-refund.php 8 years ago class-wc-order.php 8 years ago class-wc-payment-gateways.php 8 years ago class-wc-payment-tokens.php 8 years ago class-wc-post-data.php 8 years ago class-wc-post-types.php 8 years ago class-wc-privacy-background-process.php 8 years ago class-wc-privacy-erasers.php 8 years ago class-wc-privacy-exporters.php 8 years ago class-wc-privacy.php 8 years ago class-wc-product-attribute.php 8 years ago class-wc-product-download.php 8 years ago class-wc-product-external.php 8 years ago class-wc-product-factory.php 8 years ago class-wc-product-grouped.php 8 years ago class-wc-product-query.php 8 years ago class-wc-product-simple.php 8 years ago class-wc-product-variable.php 8 years ago class-wc-product-variation.php 8 years ago class-wc-query.php 8 years ago class-wc-regenerate-images-request.php 8 years ago class-wc-regenerate-images.php 8 years ago class-wc-register-wp-admin-settings.php 8 years ago class-wc-session-handler.php 8 years ago class-wc-shipping-rate.php 8 years ago class-wc-shipping-zone.php 8 years ago class-wc-shipping-zones.php 8 years ago class-wc-shipping.php 8 years ago class-wc-shortcodes.php 8 years ago class-wc-structured-data.php 8 years ago class-wc-tax.php 8 years ago class-wc-template-loader.php 8 years ago class-wc-tracker.php 8 years ago class-wc-validation.php 8 years ago class-wc-webhook.php 8 years ago class-woocommerce.php 8 years ago wc-account-functions.php 8 years ago wc-attribute-functions.php 8 years ago wc-cart-functions.php 8 years ago wc-conditional-functions.php 8 years ago wc-core-functions.php 8 years ago wc-coupon-functions.php 8 years ago wc-deprecated-functions.php 8 years ago wc-formatting-functions.php 8 years ago wc-notice-functions.php 8 years ago wc-order-functions.php 8 years ago wc-order-item-functions.php 8 years ago wc-page-functions.php 8 years ago wc-product-functions.php 8 years ago wc-rest-functions.php 8 years ago wc-stock-functions.php 8 years ago wc-template-functions.php 8 years ago wc-template-hooks.php 8 years ago wc-term-functions.php 8 years ago wc-update-functions.php 8 years ago wc-user-functions.php 8 years ago wc-webhook-functions.php 8 years ago wc-widget-functions.php 8 years ago
class-wc-logger.php
294 lines
1 <?php
2 /**
3 * Provides logging capabilities for debugging purposes.
4 *
5 * @class WC_Logger
6 * @version 2.0.0
7 * @package WooCommerce/Classes
8 */
9
10 defined( 'ABSPATH' ) || exit;
11
12 /**
13 * WC_Logger class.
14 */
15 class WC_Logger implements WC_Logger_Interface {
16
17 /**
18 * Stores registered log handlers.
19 *
20 * @var array
21 */
22 protected $handlers;
23
24 /**
25 * Minimum log level this handler will process.
26 *
27 * @var int Integer representation of minimum log level to handle.
28 */
29 protected $threshold;
30
31 /**
32 * Constructor for the logger.
33 *
34 * @param array $handlers Optional. Array of log handlers. If $handlers is not provided, the filter 'woocommerce_register_log_handlers' will be used to define the handlers. If $handlers is provided, the filter will not be applied and the handlers will be used directly.
35 * @param string $threshold Optional. Define an explicit threshold. May be configured via WC_LOG_THRESHOLD. By default, all logs will be processed.
36 */
37 public function __construct( $handlers = null, $threshold = null ) {
38 if ( null === $handlers ) {
39 $handlers = apply_filters( 'woocommerce_register_log_handlers', array() );
40 }
41
42 $register_handlers = array();
43
44 if ( ! empty( $handlers ) && is_array( $handlers ) ) {
45 foreach ( $handlers as $handler ) {
46 $implements = class_implements( $handler );
47 if ( is_object( $handler ) && is_array( $implements ) && in_array( 'WC_Log_Handler_Interface', $implements, true ) ) {
48 $register_handlers[] = $handler;
49 } else {
50 wc_doing_it_wrong(
51 __METHOD__,
52 sprintf(
53 /* translators: 1: class name 2: WC_Log_Handler_Interface */
54 __( 'The provided handler %1$s does not implement %2$s.', 'woocommerce' ),
55 '<code>' . esc_html( is_object( $handler ) ? get_class( $handler ) : $handler ) . '</code>',
56 '<code>WC_Log_Handler_Interface</code>'
57 ),
58 '3.0'
59 );
60 }
61 }
62 }
63
64 if ( null !== $threshold ) {
65 $threshold = WC_Log_Levels::get_level_severity( $threshold );
66 } elseif ( defined( 'WC_LOG_THRESHOLD' ) && WC_Log_Levels::is_valid_level( WC_LOG_THRESHOLD ) ) {
67 $threshold = WC_Log_Levels::get_level_severity( WC_LOG_THRESHOLD );
68 } else {
69 $threshold = null;
70 }
71
72 $this->handlers = $register_handlers;
73 $this->threshold = $threshold;
74 }
75
76 /**
77 * Determine whether to handle or ignore log.
78 *
79 * @param string $level emergency|alert|critical|error|warning|notice|info|debug.
80 * @return bool True if the log should be handled.
81 */
82 protected function should_handle( $level ) {
83 if ( null === $this->threshold ) {
84 return true;
85 }
86 return $this->threshold <= WC_Log_Levels::get_level_severity( $level );
87 }
88
89 /**
90 * Add a log entry.
91 *
92 * This is not the preferred method for adding log messages. Please use log() or any one of
93 * the level methods (debug(), info(), etc.). This method may be deprecated in the future.
94 *
95 * @param string $handle File handle.
96 * @param string $message Message to log.
97 * @param string $level Logging level.
98 * @return bool
99 */
100 public function add( $handle, $message, $level = WC_Log_Levels::NOTICE ) {
101 $message = apply_filters( 'woocommerce_logger_add_message', $message, $handle );
102 $this->log( $level, $message, array(
103 'source' => $handle,
104 '_legacy' => true,
105 ) );
106 wc_do_deprecated_action( 'woocommerce_log_add', array( $handle, $message ), '3.0', 'This action has been deprecated with no alternative.' );
107 return true;
108 }
109
110 /**
111 * Add a log entry.
112 *
113 * @param string $level One of the following:
114 * 'emergency': System is unusable.
115 * 'alert': Action must be taken immediately.
116 * 'critical': Critical conditions.
117 * 'error': Error conditions.
118 * 'warning': Warning conditions.
119 * 'notice': Normal but significant condition.
120 * 'info': Informational messages.
121 * 'debug': Debug-level messages.
122 * @param string $message Log message.
123 * @param array $context Optional. Additional information for log handlers.
124 */
125 public function log( $level, $message, $context = array() ) {
126 if ( ! WC_Log_Levels::is_valid_level( $level ) ) {
127 /* translators: 1: WC_Logger::log 2: level */
128 wc_doing_it_wrong( __METHOD__, sprintf( __( '%1$s was called with an invalid level "%2$s".', 'woocommerce' ), '<code>WC_Logger::log</code>', $level ), '3.0' );
129 }
130
131 if ( $this->should_handle( $level ) ) {
132 $timestamp = current_time( 'timestamp' );
133 $message = apply_filters( 'woocommerce_logger_log_message', $message, $level, $context );
134
135 foreach ( $this->handlers as $handler ) {
136 $handler->handle( $timestamp, $level, $message, $context );
137 }
138 }
139 }
140
141 /**
142 * Adds an emergency level message.
143 *
144 * System is unusable.
145 *
146 * @see WC_Logger::log
147 *
148 * @param string $message Message to log.
149 * @param array $context Log context.
150 */
151 public function emergency( $message, $context = array() ) {
152 $this->log( WC_Log_Levels::EMERGENCY, $message, $context );
153 }
154
155 /**
156 * Adds an alert level message.
157 *
158 * Action must be taken immediately.
159 * Example: Entire website down, database unavailable, etc.
160 *
161 * @see WC_Logger::log
162 *
163 * @param string $message Message to log.
164 * @param array $context Log context.
165 */
166 public function alert( $message, $context = array() ) {
167 $this->log( WC_Log_Levels::ALERT, $message, $context );
168 }
169
170 /**
171 * Adds a critical level message.
172 *
173 * Critical conditions.
174 * Example: Application component unavailable, unexpected exception.
175 *
176 * @see WC_Logger::log
177 *
178 * @param string $message Message to log.
179 * @param array $context Log context.
180 */
181 public function critical( $message, $context = array() ) {
182 $this->log( WC_Log_Levels::CRITICAL, $message, $context );
183 }
184
185 /**
186 * Adds an error level message.
187 *
188 * Runtime errors that do not require immediate action but should typically be logged
189 * and monitored.
190 *
191 * @see WC_Logger::log
192 *
193 * @param string $message Message to log.
194 * @param array $context Log context.
195 */
196 public function error( $message, $context = array() ) {
197 $this->log( WC_Log_Levels::ERROR, $message, $context );
198 }
199
200 /**
201 * Adds a warning level message.
202 *
203 * Exceptional occurrences that are not errors.
204 *
205 * Example: Use of deprecated APIs, poor use of an API, undesirable things that are not
206 * necessarily wrong.
207 *
208 * @see WC_Logger::log
209 *
210 * @param string $message Message to log.
211 * @param array $context Log context.
212 */
213 public function warning( $message, $context = array() ) {
214 $this->log( WC_Log_Levels::WARNING, $message, $context );
215 }
216
217 /**
218 * Adds a notice level message.
219 *
220 * Normal but significant events.
221 *
222 * @see WC_Logger::log
223 *
224 * @param string $message Message to log.
225 * @param array $context Log context.
226 */
227 public function notice( $message, $context = array() ) {
228 $this->log( WC_Log_Levels::NOTICE, $message, $context );
229 }
230
231 /**
232 * Adds a info level message.
233 *
234 * Interesting events.
235 * Example: User logs in, SQL logs.
236 *
237 * @see WC_Logger::log
238 *
239 * @param string $message Message to log.
240 * @param array $context Log context.
241 */
242 public function info( $message, $context = array() ) {
243 $this->log( WC_Log_Levels::INFO, $message, $context );
244 }
245
246 /**
247 * Adds a debug level message.
248 *
249 * Detailed debug information.
250 *
251 * @see WC_Logger::log
252 *
253 * @param string $message Message to log.
254 * @param array $context Log context.
255 */
256 public function debug( $message, $context = array() ) {
257 $this->log( WC_Log_Levels::DEBUG, $message, $context );
258 }
259
260 /**
261 * Clear entries for a chosen file/source.
262 *
263 * @param string $source Source/handle to clear.
264 * @return bool
265 */
266 public function clear( $source = '' ) {
267 if ( ! $source ) {
268 return false;
269 }
270 foreach ( $this->handlers as $handler ) {
271 if ( is_callable( array( $handler, 'clear' ) ) ) {
272 $handler->clear( $source );
273 }
274 }
275 return true;
276 }
277
278 /**
279 * Clear all logs older than a defined number of days. Defaults to 30 days.
280 *
281 * @since 3.4.0
282 */
283 public function clear_expired_logs() {
284 $days = absint( apply_filters( 'woocommerce_logger_days_to_retain_logs', 30 ) );
285 $timestamp = strtotime( "-{$days} days" );
286
287 foreach ( $this->handlers as $handler ) {
288 if ( is_callable( array( $handler, 'delete_logs_before_timestamp' ) ) ) {
289 $handler->delete_logs_before_timestamp( $timestamp );
290 }
291 }
292 }
293 }
294