@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | public function __construct( array $classes = [] ) { |
22 | 22 | |
23 | 23 | $this->classes = $classes + [ |
24 | - 'php' => __NAMESPACE__. '\adapter\PHPLogger', |
|
25 | - 'file' => __NAMESPACE__. '\adapter\FileLogger', |
|
26 | - 'stderr' => __NAMESPACE__. '\adapter\StdErrLogger', |
|
27 | - 'stdout' => __NAMESPACE__. '\adapter\StdOutLogger', |
|
28 | - 'syslog' => __NAMESPACE__. '\adapter\SysLogger', |
|
29 | - 'null' => __NAMESPACE__. '\adapter\NullLogger', |
|
24 | + 'php' => __NAMESPACE__.'\adapter\PHPLogger', |
|
25 | + 'file' => __NAMESPACE__.'\adapter\FileLogger', |
|
26 | + 'stderr' => __NAMESPACE__.'\adapter\StdErrLogger', |
|
27 | + 'stdout' => __NAMESPACE__.'\adapter\StdOutLogger', |
|
28 | + 'syslog' => __NAMESPACE__.'\adapter\SysLogger', |
|
29 | + 'null' => __NAMESPACE__.'\adapter\NullLogger', |
|
30 | 30 | ]; |
31 | 31 | |
32 | 32 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | 'threshold' => LogLevel::WARNING, |
47 | 47 | ); |
48 | 48 | |
49 | - switch ( $config['type'] ) { |
|
49 | + switch( $config['type'] ) { |
|
50 | 50 | case 'php': |
51 | 51 | $log = $this->createPHPLogger($config['threshold']); |
52 | 52 | break; |
@@ -66,103 +66,103 @@ |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | - * System is unusable. |
|
70 | - * |
|
71 | - * @param string $msg |
|
72 | - * @param array $context |
|
73 | - * @return $this |
|
74 | - */ |
|
75 | - public function emergency( $msg, array $context = [] ) { |
|
76 | - return $this->log(LogLevel::EMERGENCY, $msg, $context); |
|
77 | - } |
|
69 | + * System is unusable. |
|
70 | + * |
|
71 | + * @param string $msg |
|
72 | + * @param array $context |
|
73 | + * @return $this |
|
74 | + */ |
|
75 | + public function emergency( $msg, array $context = [] ) { |
|
76 | + return $this->log(LogLevel::EMERGENCY, $msg, $context); |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * Action must be taken immediately. |
|
81 | - * |
|
82 | - * Example: Entire website down, database unavailable, etc. This should |
|
83 | - * trigger the SMS alerts and wake you up. |
|
84 | - * |
|
85 | - * @param string $msg |
|
86 | - * @param array $context |
|
87 | - * @return $this |
|
88 | - */ |
|
89 | - public function alert( $msg, array $context = [] ) { |
|
90 | - return $this->log(LogLevel::ALERT, $msg, $context); |
|
91 | - } |
|
79 | + /** |
|
80 | + * Action must be taken immediately. |
|
81 | + * |
|
82 | + * Example: Entire website down, database unavailable, etc. This should |
|
83 | + * trigger the SMS alerts and wake you up. |
|
84 | + * |
|
85 | + * @param string $msg |
|
86 | + * @param array $context |
|
87 | + * @return $this |
|
88 | + */ |
|
89 | + public function alert( $msg, array $context = [] ) { |
|
90 | + return $this->log(LogLevel::ALERT, $msg, $context); |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * Critical conditions. |
|
95 | - * |
|
96 | - * Example: Application component unavailable, unexpected exception. |
|
97 | - * |
|
98 | - * @param string $msg |
|
99 | - * @param array $context |
|
100 | - * @return $this |
|
101 | - */ |
|
102 | - public function critical( $msg, array $context = [] ) { |
|
103 | - return $this->log(LogLevel::CRITICAL, $msg, $context); |
|
104 | - } |
|
93 | + /** |
|
94 | + * Critical conditions. |
|
95 | + * |
|
96 | + * Example: Application component unavailable, unexpected exception. |
|
97 | + * |
|
98 | + * @param string $msg |
|
99 | + * @param array $context |
|
100 | + * @return $this |
|
101 | + */ |
|
102 | + public function critical( $msg, array $context = [] ) { |
|
103 | + return $this->log(LogLevel::CRITICAL, $msg, $context); |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Runtime errors that do not require immediate action but should typically |
|
108 | - * be logged and monitored. |
|
109 | - * |
|
110 | - * @param string $msg |
|
111 | - * @param array $context |
|
112 | - * @return $this |
|
113 | - */ |
|
114 | - public function error( $msg, array $context = [] ) { |
|
115 | - return $this->log(LogLevel::ERROR, $msg, $context); |
|
116 | - } |
|
106 | + /** |
|
107 | + * Runtime errors that do not require immediate action but should typically |
|
108 | + * be logged and monitored. |
|
109 | + * |
|
110 | + * @param string $msg |
|
111 | + * @param array $context |
|
112 | + * @return $this |
|
113 | + */ |
|
114 | + public function error( $msg, array $context = [] ) { |
|
115 | + return $this->log(LogLevel::ERROR, $msg, $context); |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * Exceptional occurrences that are not errors. |
|
120 | - * |
|
121 | - * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
122 | - * that are not necessarily wrong. |
|
123 | - * |
|
124 | - * @param string $msg |
|
125 | - * @param array $context |
|
126 | - * @return $this |
|
127 | - */ |
|
128 | - public function warning( $msg, array $context = [] ) { |
|
129 | - return $this->log(LogLevel::WARNING, $msg, $context); |
|
130 | - } |
|
118 | + /** |
|
119 | + * Exceptional occurrences that are not errors. |
|
120 | + * |
|
121 | + * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
122 | + * that are not necessarily wrong. |
|
123 | + * |
|
124 | + * @param string $msg |
|
125 | + * @param array $context |
|
126 | + * @return $this |
|
127 | + */ |
|
128 | + public function warning( $msg, array $context = [] ) { |
|
129 | + return $this->log(LogLevel::WARNING, $msg, $context); |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * Normal but significant events. |
|
134 | - * |
|
135 | - * @param string $msg |
|
136 | - * @param array $context |
|
137 | - * @return $this |
|
138 | - */ |
|
139 | - public function notice( $msg, array $context = [] ) { |
|
140 | - return $this->log(LogLevel::NOTICE, $msg, $context); |
|
141 | - } |
|
132 | + /** |
|
133 | + * Normal but significant events. |
|
134 | + * |
|
135 | + * @param string $msg |
|
136 | + * @param array $context |
|
137 | + * @return $this |
|
138 | + */ |
|
139 | + public function notice( $msg, array $context = [] ) { |
|
140 | + return $this->log(LogLevel::NOTICE, $msg, $context); |
|
141 | + } |
|
142 | 142 | |
143 | - /** |
|
144 | - * Interesting events. |
|
145 | - * |
|
146 | - * Example: User logs in, SQL logs. |
|
147 | - * |
|
148 | - * @param string $msg |
|
149 | - * @param array $context |
|
150 | - * @return $this |
|
151 | - */ |
|
152 | - public function info( $msg, array $context = [] ) { |
|
153 | - return $this->log(LogLevel::INFO, $msg, $context); |
|
154 | - } |
|
143 | + /** |
|
144 | + * Interesting events. |
|
145 | + * |
|
146 | + * Example: User logs in, SQL logs. |
|
147 | + * |
|
148 | + * @param string $msg |
|
149 | + * @param array $context |
|
150 | + * @return $this |
|
151 | + */ |
|
152 | + public function info( $msg, array $context = [] ) { |
|
153 | + return $this->log(LogLevel::INFO, $msg, $context); |
|
154 | + } |
|
155 | 155 | |
156 | - /** |
|
157 | - * Detailed debug information. |
|
158 | - * |
|
159 | - * @param string $msg |
|
160 | - * @param array $context |
|
161 | - * @return $this |
|
162 | - */ |
|
163 | - public function debug( $msg, array $context = [] ) { |
|
164 | - return $this->log(LogLevel::DEBUG, $msg, $context); |
|
165 | - } |
|
156 | + /** |
|
157 | + * Detailed debug information. |
|
158 | + * |
|
159 | + * @param string $msg |
|
160 | + * @param array $context |
|
161 | + * @return $this |
|
162 | + */ |
|
163 | + public function debug( $msg, array $context = [] ) { |
|
164 | + return $this->log(LogLevel::DEBUG, $msg, $context); |
|
165 | + } |
|
166 | 166 | |
167 | 167 | /** |
168 | 168 | * Log a message of a specific level. |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | public function __construct( $prefix = '' ) { |
33 | 33 | parent::__construct(); |
34 | 34 | $prefix = trim($prefix); |
35 | - $this->prefix = $prefix ? $prefix. ': ' : ''; |
|
35 | + $this->prefix = $prefix ? $prefix.': ' : ''; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | protected function output( $level, $msg ) { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | $priority = isset($priorities[$level]) ? $priorities[$level] : LOG_INFO; |
53 | 53 | |
54 | - syslog($priority, $this->prefix. $msg); |
|
54 | + syslog($priority, $this->prefix.$msg); |
|
55 | 55 | |
56 | 56 | } |
57 | 57 |
@@ -32,7 +32,7 @@ |
||
32 | 32 | public function __construct( $stream ) { |
33 | 33 | |
34 | 34 | if( !is_resource($stream) || (get_resource_type($stream) != 'stream') ) |
35 | - throw new Exception('Not a valid stream: '. gettype($stream)); |
|
35 | + throw new Exception('Not a valid stream: '.gettype($stream)); |
|
36 | 36 | |
37 | 37 | $this->stream = $stream; |
38 | 38 |