PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 2.2.11
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v2.2.11
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 3.8.0 All 110 releases
wp-optimize / includes / class-updraft-php-logger.php

class-updraft-php-logger.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 2.2.11, at includes/class-updraft-php-logger.php

131 lines 2.7 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 if (class_exists('Updraft_PHP_Logger')) return;
6
7 /**
8 * Class Updraft_PHP_Logger
9 */
10 class Updraft_PHP_Logger extends Updraft_Abstract_Logger {
11
12 /**
13 * Updraft_PHP_Logger constructor
14 */
15 public function __construct() {
16 }
17
18 /**
19 * Returns logger description
20 *
21 * @return string|void
22 */
23 public function get_description() {
24 return __('Log events into the PHP error log', 'wp-optimize');
25 }
26
27 /**
28 * Emergency message
29 *
30 * @param string $message
31 * @param array $context
32 * @return null|void
33 */
34 public function emergency($message, array $context = array()) {
35 $this->log(Updraft_Log_Levels::EMERGENCY, $message, $context);
36 }
37
38 /**
39 * Alert message
40 *
41 * @param string $message
42 * @param array $context
43 * @return null|void
44 */
45 public function alert($message, array $context = array()) {
46 $this->log(Updraft_Log_Levels::ALERT, $message, $context);
47 }
48
49 /**
50 * Critical message
51 *
52 * @param string $message
53 * @param array $context
54 * @return null|void
55 */
56 public function critical($message, array $context = array()) {
57 $this->log(Updraft_Log_Levels::CRITICAL, $message, $context);
58 }
59
60 /**
61 * Error message
62 *
63 * @param string $message
64 * @param array $context
65 * @return null|void
66 */
67 public function error($message, array $context = array()) {
68 $this->log(Updraft_Log_Levels::ERROR, $message, $context);
69 }
70
71 /**
72 * Warning message
73 *
74 * @param string $message
75 * @param array $context
76 * @return null|void
77 */
78 public function warning($message, array $context = array()) {
79 $this->log(Updraft_Log_Levels::WARNING, $message, $context);
80 }
81
82 /**
83 * Notice message
84 *
85 * @param string $message
86 * @param array $context
87 * @return null|void
88 */
89 public function notice($message, array $context = array()) {
90 $this->log(Updraft_Log_Levels::NOTICE, $message, $context);
91 }
92
93 /**
94 * Info message
95 *
96 * @param string $message
97 * @param array $context
98 * @return null|void
99 */
100 public function info($message, array $context = array()) {
101 $this->log(Updraft_Log_Levels::INFO, $message, $context);
102 }
103
104 /**
105 * Debug message
106 *
107 * @param string $message
108 * @param array $context
109 * @return null|void
110 */
111 public function debug($message, array $context = array()) {
112 $this->log(Updraft_Log_Levels::DEBUG, $message, $context);
113 }
114
115 /**
116 * Log message with any level
117 *
118 * @param mixed $level
119 * @param string $message
120 * @param array $context
121 * @return null|void
122 */
123 public function log($level, $message, array $context = array()) {
124
125 if (!$this->is_enabled()) return false;
126
127 $message = '['.Updraft_Log_Levels::to_text($level).'] : '.$this->interpolate($message, $context);
128 error_log($message);
129 }
130 }
131