PluginProbe
UpdraftCentral Dashboard / trunk
UpdraftCentral Dashboard vtrunk
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-updraftcentral-php-logger.php

class-updraftcentral-php-logger.php in UpdraftCentral Dashboard trunk, at classes/class-updraftcentral-php-logger.php

139 lines 3.1 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('UpdraftCentral_PHP_Logger')) return;
6
7 /**
8 * Class UpdraftCentral_PHP_Logger
9 */
10 class UpdraftCentral_PHP_Logger extends UpdraftCentral_Abstract_Logger {
11
12 /**
13 * UpdraftCentral_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', 'updraftcentral');
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($message, UpdraftCentral_Log_Levels::EMERGENCY, $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($message, UpdraftCentral_Log_Levels::ALERT, $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($message, UpdraftCentral_Log_Levels::CRITICAL, $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($message, UpdraftCentral_Log_Levels::ERROR, $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($message, UpdraftCentral_Log_Levels::WARNING, $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($message, UpdraftCentral_Log_Levels::NOTICE, $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 if (defined('WP_DEBUG') && WP_DEBUG) $this->log($message, UpdraftCentral_Log_Levels::INFO, $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 if (defined('WP_DEBUG') && WP_DEBUG) $this->log($message, UpdraftCentral_Log_Levels::DEBUG, $context);
113 }
114
115 /**
116 * Log message with any level
117 *
118 * @param string $message
119 * @param mixed $level
120 * @param array $context
121 * @return null|void
122 */
123 public function log($message, $level, array $context = array()) {
124
125 if (!$this->is_enabled()) return false;
126
127 $message = '['.UpdraftCentral_Log_Levels::to_text($level).'] : '.$this->interpolate($message, $context);
128
129 // If WP_DEBUG is on, log everything; otherwise, ignore debug and info since they do not indicate any problems.
130 if (defined('WP_DEBUG') && WP_DEBUG) {
131 error_log($message);
132 } else {
133 if (!in_array($level, array('debug', 'info'))) {
134 error_log($message);
135 }
136 }
137 }
138 }
139