PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.0.7
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.0.7
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / classes / WpMatomo / WpStatistics / Logger / WpCliLogger.php
matomo / classes / WpMatomo / WpStatistics / Logger Last commit date
EchoLogger.php 4 years ago WpCliLogger.php 4 years ago
WpCliLogger.php
164 lines
1 <?php
2
3 namespace WpMatomo\WpStatistics\Logger;
4
5 use WP_CLI;
6 use Psr\Log\LoggerInterface;
7
8 /**
9 * WP_CLi logger
10 *
11 * @package WpMatomo
12 * @subpackage WpStatisticsImport
13 */
14 class WpCliLogger implements LoggerInterface {
15
16 public function debug( $message, array $context = array() ) {
17 WP_CLI::log(
18 '[debug] ' . str_replace(
19 array_map(
20 [
21 $this,
22 'getContext',
23 ],
24 array_keys( $context )
25 ),
26 array_values( $context ),
27 $message
28 )
29 );
30 }
31
32 public function error( $message, array $context = array() ) {
33 WP_CLI::log(
34 '[error] ' . str_replace(
35 array_map(
36 [
37 $this,
38 'getContext',
39 ],
40 array_keys( $context )
41 ),
42 array_values( $context ),
43 $message
44 )
45 );
46 }
47
48 public function critical( $message, array $context = array() ) {
49 WP_CLI::log(
50 '[critical] ' . str_replace(
51 array_map(
52 [
53 $this,
54 'getContext',
55 ],
56 array_keys( $context )
57 ),
58 array_values( $context ),
59 $message
60 )
61 );
62 }
63
64 public function warning( $message, array $context = array() ) {
65 WP_CLI::log(
66 '[warning] ' . str_replace(
67 array_map(
68 [
69 $this,
70 'getContext',
71 ],
72 array_keys( $context )
73 ),
74 array_values( $context ),
75 $message
76 )
77 );
78 }
79
80 public function info( $message, array $context = array() ) {
81 WP_CLI::log(
82 '[info] ' . str_replace(
83 array_map(
84 [
85 $this,
86 'getContext',
87 ],
88 array_keys( $context )
89 ),
90 array_values( $context ),
91 $message
92 )
93 );
94 }
95
96 public function log( $level, $message, array $context = array() ) {
97 WP_CLI::log(
98 '[' . $level . '] ' . str_replace(
99 array_map(
100 [
101 $this,
102 'getContext',
103 ],
104 array_keys( $context )
105 ),
106 array_values( $context ),
107 $message
108 )
109 );
110 }
111
112 public function notice( $message, array $context = array() ) {
113 WP_CLI::log(
114 '[notice] ' . str_replace(
115 array_map(
116 [
117 $this,
118 'getContext',
119 ],
120 array_keys( $context )
121 ),
122 array_values( $context ),
123 $message
124 )
125 );
126 }
127
128 public function alert( $message, array $context = array() ) {
129 WP_CLI::log(
130 '[alert] ' . str_replace(
131 array_map(
132 [
133 $this,
134 'getContext',
135 ],
136 array_keys( $context )
137 ),
138 array_values( $context ),
139 $message
140 )
141 );
142 }
143
144 public function emergency( $message, array $context = array() ) {
145 WP_CLI::log(
146 '[emergency] ' . str_replace(
147 array_map(
148 [
149 $this,
150 'getContext',
151 ],
152 array_keys( $context )
153 ),
154 array_values( $context ),
155 $message
156 )
157 );
158 }
159
160 public function getContext( $context ) {
161 return '{' . $context . '}';
162 }
163 }
164