PluginProbe
WP Directory Kit / 1.3.1
WP Directory Kit v1.3.1
1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 1.4.0 1.4.1 All 35 releases
wpdirectorykit / vendor / WordPress-Importer / class-logger.php

class-logger.php in WP Directory Kit 1.3.1, at vendor/WordPress-Importer/class-logger.php

137 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Describes a logger instance
5 *
6 * Based on PSR-3: http://www.php-fig.org/psr/psr-3/
7 *
8 * The message MUST be a string or object implementing __toString().
9 *
10 * The message MAY contain placeholders in the form: {foo} where foo
11 * will be replaced by the context data in key "foo".
12 *
13 * The context array can contain arbitrary data, the only assumption that
14 * can be made by implementors is that if an Exception instance is given
15 * to produce a stack trace, it MUST be in a key named "exception".
16 *
17 * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
18 * for the full interface specification.
19 */
20 class WP_Importer_Logger {
21 /**
22 * System is unusable.
23 *
24 * @param string $message
25 * @param array $context
26 * @return null
27 */
28 public function emergency( $message, array $context = array() ) {
29 return $this->log( 'emergency', $message, $context );
30 }
31
32 /**
33 * Action must be taken immediately.
34 *
35 * Example: Entire website down, database unavailable, etc. This should
36 * trigger the SMS alerts and wake you up.
37 *
38 * @param string $message
39 * @param array $context
40 * @return null
41 */
42 public function alert( $message, array $context = array() ) {
43 return $this->log( 'alert', $message, $context );
44 }
45
46 /**
47 * Critical conditions.
48 *
49 * Example: Application component unavailable, unexpected exception.
50 *
51 * @param string $message
52 * @param array $context
53 * @return null
54 */
55 public function critical( $message, array $context = array() ) {
56 return $this->log( 'critical', $message, $context );
57 }
58
59 /**
60 * Runtime errors that do not require immediate action but should typically
61 * be logged and monitored.
62 *
63 * @param string $message
64 * @param array $context
65 * @return null
66 */
67 public function error( $message, array $context = array()) {
68 return $this->log( 'error', $message, $context );
69 }
70
71 /**
72 * Exceptional occurrences that are not errors.
73 *
74 * Example: Use of deprecated APIs, poor use of an API, undesirable things
75 * that are not necessarily wrong.
76 *
77 * @param string $message
78 * @param array $context
79 * @return null
80 */
81 public function warning( $message, array $context = array() ) {
82 return $this->log( 'warning', $message, $context );
83 }
84
85 /**
86 * Normal but significant events.
87 *
88 * @param string $message
89 * @param array $context
90 * @return null
91 */
92 public function notice( $message, array $context = array() ) {
93 return $this->log( 'notice', $message, $context );
94 }
95
96 /**
97 * Interesting events.
98 *
99 * Example: User logs in, SQL logs.
100 *
101 * @param string $message
102 * @param array $context
103 * @return null
104 */
105 public function info( $message, array $context = array() ) {
106 return $this->log( 'info', $message, $context );
107 }
108
109 /**
110 * Detailed debug information.
111 *
112 * @param string $message
113 * @param array $context
114 * @return null
115 */
116 public function debug( $message, array $context = array() ) {
117 return $this->log( 'debug', $message, $context );
118 }
119
120 /**
121 * Logs with an arbitrary level.
122 *
123 * @param mixed $level
124 * @param string $message
125 * @param array $context
126 * @return null
127 */
128 public function log( $level, $message, array $context = array() ) {
129 $this->messages[] = array(
130 'timestamp' => time(),
131 'level' => $level,
132 'message' => $message,
133 'context' => $context,
134 );
135 }
136 }
137