PluginProbe
Image Optimization – Compress Images and Convert to WebP or AVIF / 1.6.6
Image Optimization – Compress Images and Convert to WebP or AVIF v1.6.6
1.7.6 1.7.5 1.7.4 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 All 32 releases
image-optimization / classes / logger.php

logger.php in Image Optimization – Compress Images and Convert to WebP or AVIF 1.6.6, at classes/logger.php

30 lines 877 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ImageOptimization\Classes;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit; // Exit if accessed directly.
7 }
8
9 class Logger {
10 public const LEVEL_ERROR = 'error';
11 public const LEVEL_WARN = 'warn';
12 public const LEVEL_INFO = 'info';
13
14 public static function log( string $log_level, $message ): void {
15 $backtrace = debug_backtrace(); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace
16
17 $class = $backtrace[1]['class'] ?? null;
18 $type = $backtrace[1]['type'] ?? null;
19 $function = $backtrace[1]['function'];
20
21 if ( $class ) {
22 $message = '[Image Optimizer]: ' . $log_level . ' in ' . "$class$type$function()" . ': ' . $message;
23 } else {
24 $message = '[Image Optimizer]: ' . $log_level . ' in ' . "$function()" . ': ' . $message;
25 }
26
27 error_log( $message ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
28 }
29 }
30