@@ -12,131 +12,131 @@ |
||
12 | 12 | */ |
13 | 13 | trait LoggerTrait |
14 | 14 | { |
15 | - /** |
|
16 | - * System is unusable. |
|
17 | - * |
|
18 | - * @param string $message |
|
19 | - * @param array $context |
|
20 | - * |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function emergency($message, array $context = array()) |
|
24 | - { |
|
25 | - $this->log(LogLevel::EMERGENCY, $message, $context); |
|
26 | - } |
|
15 | + /** |
|
16 | + * System is unusable. |
|
17 | + * |
|
18 | + * @param string $message |
|
19 | + * @param array $context |
|
20 | + * |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function emergency($message, array $context = array()) |
|
24 | + { |
|
25 | + $this->log(LogLevel::EMERGENCY, $message, $context); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Action must be taken immediately. |
|
30 | - * |
|
31 | - * Example: Entire website down, database unavailable, etc. This should |
|
32 | - * trigger the SMS alerts and wake you up. |
|
33 | - * |
|
34 | - * @param string $message |
|
35 | - * @param array $context |
|
36 | - * |
|
37 | - * @return void |
|
38 | - */ |
|
39 | - public function alert($message, array $context = array()) |
|
40 | - { |
|
41 | - $this->log(LogLevel::ALERT, $message, $context); |
|
42 | - } |
|
28 | + /** |
|
29 | + * Action must be taken immediately. |
|
30 | + * |
|
31 | + * Example: Entire website down, database unavailable, etc. This should |
|
32 | + * trigger the SMS alerts and wake you up. |
|
33 | + * |
|
34 | + * @param string $message |
|
35 | + * @param array $context |
|
36 | + * |
|
37 | + * @return void |
|
38 | + */ |
|
39 | + public function alert($message, array $context = array()) |
|
40 | + { |
|
41 | + $this->log(LogLevel::ALERT, $message, $context); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Critical conditions. |
|
46 | - * |
|
47 | - * Example: Application component unavailable, unexpected exception. |
|
48 | - * |
|
49 | - * @param string $message |
|
50 | - * @param array $context |
|
51 | - * |
|
52 | - * @return void |
|
53 | - */ |
|
54 | - public function critical($message, array $context = array()) |
|
55 | - { |
|
56 | - $this->log(LogLevel::CRITICAL, $message, $context); |
|
57 | - } |
|
44 | + /** |
|
45 | + * Critical conditions. |
|
46 | + * |
|
47 | + * Example: Application component unavailable, unexpected exception. |
|
48 | + * |
|
49 | + * @param string $message |
|
50 | + * @param array $context |
|
51 | + * |
|
52 | + * @return void |
|
53 | + */ |
|
54 | + public function critical($message, array $context = array()) |
|
55 | + { |
|
56 | + $this->log(LogLevel::CRITICAL, $message, $context); |
|
57 | + } |
|
58 | 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 | - * |
|
66 | - * @return void |
|
67 | - */ |
|
68 | - public function error($message, array $context = array()) |
|
69 | - { |
|
70 | - $this->log(LogLevel::ERROR, $message, $context); |
|
71 | - } |
|
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 | + * |
|
66 | + * @return void |
|
67 | + */ |
|
68 | + public function error($message, array $context = array()) |
|
69 | + { |
|
70 | + $this->log(LogLevel::ERROR, $message, $context); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Exceptional occurrences that are not errors. |
|
75 | - * |
|
76 | - * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
77 | - * that are not necessarily wrong. |
|
78 | - * |
|
79 | - * @param string $message |
|
80 | - * @param array $context |
|
81 | - * |
|
82 | - * @return void |
|
83 | - */ |
|
84 | - public function warning($message, array $context = array()) |
|
85 | - { |
|
86 | - $this->log(LogLevel::WARNING, $message, $context); |
|
87 | - } |
|
73 | + /** |
|
74 | + * Exceptional occurrences that are not errors. |
|
75 | + * |
|
76 | + * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
77 | + * that are not necessarily wrong. |
|
78 | + * |
|
79 | + * @param string $message |
|
80 | + * @param array $context |
|
81 | + * |
|
82 | + * @return void |
|
83 | + */ |
|
84 | + public function warning($message, array $context = array()) |
|
85 | + { |
|
86 | + $this->log(LogLevel::WARNING, $message, $context); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Normal but significant events. |
|
91 | - * |
|
92 | - * @param string $message |
|
93 | - * @param array $context |
|
94 | - * |
|
95 | - * @return void |
|
96 | - */ |
|
97 | - public function notice($message, array $context = array()) |
|
98 | - { |
|
99 | - $this->log(LogLevel::NOTICE, $message, $context); |
|
100 | - } |
|
89 | + /** |
|
90 | + * Normal but significant events. |
|
91 | + * |
|
92 | + * @param string $message |
|
93 | + * @param array $context |
|
94 | + * |
|
95 | + * @return void |
|
96 | + */ |
|
97 | + public function notice($message, array $context = array()) |
|
98 | + { |
|
99 | + $this->log(LogLevel::NOTICE, $message, $context); |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * Interesting events. |
|
104 | - * |
|
105 | - * Example: User logs in, SQL logs. |
|
106 | - * |
|
107 | - * @param string $message |
|
108 | - * @param array $context |
|
109 | - * |
|
110 | - * @return void |
|
111 | - */ |
|
112 | - public function info($message, array $context = array()) |
|
113 | - { |
|
114 | - $this->log(LogLevel::INFO, $message, $context); |
|
115 | - } |
|
102 | + /** |
|
103 | + * Interesting events. |
|
104 | + * |
|
105 | + * Example: User logs in, SQL logs. |
|
106 | + * |
|
107 | + * @param string $message |
|
108 | + * @param array $context |
|
109 | + * |
|
110 | + * @return void |
|
111 | + */ |
|
112 | + public function info($message, array $context = array()) |
|
113 | + { |
|
114 | + $this->log(LogLevel::INFO, $message, $context); |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * Detailed debug information. |
|
119 | - * |
|
120 | - * @param string $message |
|
121 | - * @param array $context |
|
122 | - * |
|
123 | - * @return void |
|
124 | - */ |
|
125 | - public function debug($message, array $context = array()) |
|
126 | - { |
|
127 | - $this->log(LogLevel::DEBUG, $message, $context); |
|
128 | - } |
|
117 | + /** |
|
118 | + * Detailed debug information. |
|
119 | + * |
|
120 | + * @param string $message |
|
121 | + * @param array $context |
|
122 | + * |
|
123 | + * @return void |
|
124 | + */ |
|
125 | + public function debug($message, array $context = array()) |
|
126 | + { |
|
127 | + $this->log(LogLevel::DEBUG, $message, $context); |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * Logs with an arbitrary level. |
|
132 | - * |
|
133 | - * @param mixed $level |
|
134 | - * @param string $message |
|
135 | - * @param array $context |
|
136 | - * |
|
137 | - * @return void |
|
138 | - * |
|
139 | - * @throws \OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Log\InvalidArgumentException |
|
140 | - */ |
|
141 | - abstract public function log($level, $message, array $context = array()); |
|
130 | + /** |
|
131 | + * Logs with an arbitrary level. |
|
132 | + * |
|
133 | + * @param mixed $level |
|
134 | + * @param string $message |
|
135 | + * @param array $context |
|
136 | + * |
|
137 | + * @return void |
|
138 | + * |
|
139 | + * @throws \OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Log\InvalidArgumentException |
|
140 | + */ |
|
141 | + abstract public function log($level, $message, array $context = array()); |
|
142 | 142 | } |
@@ -10,8 +10,7 @@ |
||
10 | 10 | * reduce boilerplate code that a simple Logger that does the same thing with |
11 | 11 | * messages regardless of the error level has to implement. |
12 | 12 | */ |
13 | -trait LoggerTrait |
|
14 | -{ |
|
13 | +trait LoggerTrait { |
|
15 | 14 | /** |
16 | 15 | * System is unusable. |
17 | 16 | * |
@@ -19,107 +19,107 @@ |
||
19 | 19 | */ |
20 | 20 | interface LoggerInterface |
21 | 21 | { |
22 | - /** |
|
23 | - * System is unusable. |
|
24 | - * |
|
25 | - * @param string $message |
|
26 | - * @param mixed[] $context |
|
27 | - * |
|
28 | - * @return void |
|
29 | - */ |
|
30 | - public function emergency($message, array $context = array()); |
|
22 | + /** |
|
23 | + * System is unusable. |
|
24 | + * |
|
25 | + * @param string $message |
|
26 | + * @param mixed[] $context |
|
27 | + * |
|
28 | + * @return void |
|
29 | + */ |
|
30 | + public function emergency($message, array $context = array()); |
|
31 | 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 mixed[] $context |
|
40 | - * |
|
41 | - * @return void |
|
42 | - */ |
|
43 | - public function alert($message, array $context = array()); |
|
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 mixed[] $context |
|
40 | + * |
|
41 | + * @return void |
|
42 | + */ |
|
43 | + public function alert($message, array $context = array()); |
|
44 | 44 | |
45 | - /** |
|
46 | - * Critical conditions. |
|
47 | - * |
|
48 | - * Example: Application component unavailable, unexpected exception. |
|
49 | - * |
|
50 | - * @param string $message |
|
51 | - * @param mixed[] $context |
|
52 | - * |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function critical($message, array $context = array()); |
|
45 | + /** |
|
46 | + * Critical conditions. |
|
47 | + * |
|
48 | + * Example: Application component unavailable, unexpected exception. |
|
49 | + * |
|
50 | + * @param string $message |
|
51 | + * @param mixed[] $context |
|
52 | + * |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function critical($message, array $context = array()); |
|
56 | 56 | |
57 | - /** |
|
58 | - * Runtime errors that do not require immediate action but should typically |
|
59 | - * be logged and monitored. |
|
60 | - * |
|
61 | - * @param string $message |
|
62 | - * @param mixed[] $context |
|
63 | - * |
|
64 | - * @return void |
|
65 | - */ |
|
66 | - public function error($message, array $context = array()); |
|
57 | + /** |
|
58 | + * Runtime errors that do not require immediate action but should typically |
|
59 | + * be logged and monitored. |
|
60 | + * |
|
61 | + * @param string $message |
|
62 | + * @param mixed[] $context |
|
63 | + * |
|
64 | + * @return void |
|
65 | + */ |
|
66 | + public function error($message, array $context = array()); |
|
67 | 67 | |
68 | - /** |
|
69 | - * Exceptional occurrences that are not errors. |
|
70 | - * |
|
71 | - * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
72 | - * that are not necessarily wrong. |
|
73 | - * |
|
74 | - * @param string $message |
|
75 | - * @param mixed[] $context |
|
76 | - * |
|
77 | - * @return void |
|
78 | - */ |
|
79 | - public function warning($message, array $context = array()); |
|
68 | + /** |
|
69 | + * Exceptional occurrences that are not errors. |
|
70 | + * |
|
71 | + * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
72 | + * that are not necessarily wrong. |
|
73 | + * |
|
74 | + * @param string $message |
|
75 | + * @param mixed[] $context |
|
76 | + * |
|
77 | + * @return void |
|
78 | + */ |
|
79 | + public function warning($message, array $context = array()); |
|
80 | 80 | |
81 | - /** |
|
82 | - * Normal but significant events. |
|
83 | - * |
|
84 | - * @param string $message |
|
85 | - * @param mixed[] $context |
|
86 | - * |
|
87 | - * @return void |
|
88 | - */ |
|
89 | - public function notice($message, array $context = array()); |
|
81 | + /** |
|
82 | + * Normal but significant events. |
|
83 | + * |
|
84 | + * @param string $message |
|
85 | + * @param mixed[] $context |
|
86 | + * |
|
87 | + * @return void |
|
88 | + */ |
|
89 | + public function notice($message, array $context = array()); |
|
90 | 90 | |
91 | - /** |
|
92 | - * Interesting events. |
|
93 | - * |
|
94 | - * Example: User logs in, SQL logs. |
|
95 | - * |
|
96 | - * @param string $message |
|
97 | - * @param mixed[] $context |
|
98 | - * |
|
99 | - * @return void |
|
100 | - */ |
|
101 | - public function info($message, array $context = array()); |
|
91 | + /** |
|
92 | + * Interesting events. |
|
93 | + * |
|
94 | + * Example: User logs in, SQL logs. |
|
95 | + * |
|
96 | + * @param string $message |
|
97 | + * @param mixed[] $context |
|
98 | + * |
|
99 | + * @return void |
|
100 | + */ |
|
101 | + public function info($message, array $context = array()); |
|
102 | 102 | |
103 | - /** |
|
104 | - * Detailed debug information. |
|
105 | - * |
|
106 | - * @param string $message |
|
107 | - * @param mixed[] $context |
|
108 | - * |
|
109 | - * @return void |
|
110 | - */ |
|
111 | - public function debug($message, array $context = array()); |
|
103 | + /** |
|
104 | + * Detailed debug information. |
|
105 | + * |
|
106 | + * @param string $message |
|
107 | + * @param mixed[] $context |
|
108 | + * |
|
109 | + * @return void |
|
110 | + */ |
|
111 | + public function debug($message, array $context = array()); |
|
112 | 112 | |
113 | - /** |
|
114 | - * Logs with an arbitrary level. |
|
115 | - * |
|
116 | - * @param mixed $level |
|
117 | - * @param string $message |
|
118 | - * @param mixed[] $context |
|
119 | - * |
|
120 | - * @return void |
|
121 | - * |
|
122 | - * @throws \OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Log\InvalidArgumentException |
|
123 | - */ |
|
124 | - public function log($level, $message, array $context = array()); |
|
113 | + /** |
|
114 | + * Logs with an arbitrary level. |
|
115 | + * |
|
116 | + * @param mixed $level |
|
117 | + * @param string $message |
|
118 | + * @param mixed[] $context |
|
119 | + * |
|
120 | + * @return void |
|
121 | + * |
|
122 | + * @throws \OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Log\InvalidArgumentException |
|
123 | + */ |
|
124 | + public function log($level, $message, array $context = array()); |
|
125 | 125 | } |
@@ -17,8 +17,7 @@ |
||
17 | 17 | * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md |
18 | 18 | * for the full interface specification. |
19 | 19 | */ |
20 | -interface LoggerInterface |
|
21 | -{ |
|
20 | +interface LoggerInterface { |
|
22 | 21 | /** |
23 | 22 | * System is unusable. |
24 | 23 | * |
@@ -7,12 +7,12 @@ |
||
7 | 7 | */ |
8 | 8 | class LogLevel |
9 | 9 | { |
10 | - const EMERGENCY = 'emergency'; |
|
11 | - const ALERT = 'alert'; |
|
12 | - const CRITICAL = 'critical'; |
|
13 | - const ERROR = 'error'; |
|
14 | - const WARNING = 'warning'; |
|
15 | - const NOTICE = 'notice'; |
|
16 | - const INFO = 'info'; |
|
17 | - const DEBUG = 'debug'; |
|
10 | + const EMERGENCY = 'emergency'; |
|
11 | + const ALERT = 'alert'; |
|
12 | + const CRITICAL = 'critical'; |
|
13 | + const ERROR = 'error'; |
|
14 | + const WARNING = 'warning'; |
|
15 | + const NOTICE = 'notice'; |
|
16 | + const INFO = 'info'; |
|
17 | + const DEBUG = 'debug'; |
|
18 | 18 | } |
@@ -5,8 +5,7 @@ |
||
5 | 5 | /** |
6 | 6 | * Describes log levels. |
7 | 7 | */ |
8 | -class LogLevel |
|
9 | -{ |
|
8 | +class LogLevel { |
|
10 | 9 | const EMERGENCY = 'emergency'; |
11 | 10 | const ALERT = 'alert'; |
12 | 11 | const CRITICAL = 'critical'; |
@@ -11,118 +11,118 @@ |
||
11 | 11 | */ |
12 | 12 | abstract class AbstractLogger implements LoggerInterface |
13 | 13 | { |
14 | - /** |
|
15 | - * System is unusable. |
|
16 | - * |
|
17 | - * @param string $message |
|
18 | - * @param mixed[] $context |
|
19 | - * |
|
20 | - * @return void |
|
21 | - */ |
|
22 | - public function emergency($message, array $context = array()) |
|
23 | - { |
|
24 | - $this->log(LogLevel::EMERGENCY, $message, $context); |
|
25 | - } |
|
14 | + /** |
|
15 | + * System is unusable. |
|
16 | + * |
|
17 | + * @param string $message |
|
18 | + * @param mixed[] $context |
|
19 | + * |
|
20 | + * @return void |
|
21 | + */ |
|
22 | + public function emergency($message, array $context = array()) |
|
23 | + { |
|
24 | + $this->log(LogLevel::EMERGENCY, $message, $context); |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Action must be taken immediately. |
|
29 | - * |
|
30 | - * Example: Entire website down, database unavailable, etc. This should |
|
31 | - * trigger the SMS alerts and wake you up. |
|
32 | - * |
|
33 | - * @param string $message |
|
34 | - * @param mixed[] $context |
|
35 | - * |
|
36 | - * @return void |
|
37 | - */ |
|
38 | - public function alert($message, array $context = array()) |
|
39 | - { |
|
40 | - $this->log(LogLevel::ALERT, $message, $context); |
|
41 | - } |
|
27 | + /** |
|
28 | + * Action must be taken immediately. |
|
29 | + * |
|
30 | + * Example: Entire website down, database unavailable, etc. This should |
|
31 | + * trigger the SMS alerts and wake you up. |
|
32 | + * |
|
33 | + * @param string $message |
|
34 | + * @param mixed[] $context |
|
35 | + * |
|
36 | + * @return void |
|
37 | + */ |
|
38 | + public function alert($message, array $context = array()) |
|
39 | + { |
|
40 | + $this->log(LogLevel::ALERT, $message, $context); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Critical conditions. |
|
45 | - * |
|
46 | - * Example: Application component unavailable, unexpected exception. |
|
47 | - * |
|
48 | - * @param string $message |
|
49 | - * @param mixed[] $context |
|
50 | - * |
|
51 | - * @return void |
|
52 | - */ |
|
53 | - public function critical($message, array $context = array()) |
|
54 | - { |
|
55 | - $this->log(LogLevel::CRITICAL, $message, $context); |
|
56 | - } |
|
43 | + /** |
|
44 | + * Critical conditions. |
|
45 | + * |
|
46 | + * Example: Application component unavailable, unexpected exception. |
|
47 | + * |
|
48 | + * @param string $message |
|
49 | + * @param mixed[] $context |
|
50 | + * |
|
51 | + * @return void |
|
52 | + */ |
|
53 | + public function critical($message, array $context = array()) |
|
54 | + { |
|
55 | + $this->log(LogLevel::CRITICAL, $message, $context); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * Runtime errors that do not require immediate action but should typically |
|
60 | - * be logged and monitored. |
|
61 | - * |
|
62 | - * @param string $message |
|
63 | - * @param mixed[] $context |
|
64 | - * |
|
65 | - * @return void |
|
66 | - */ |
|
67 | - public function error($message, array $context = array()) |
|
68 | - { |
|
69 | - $this->log(LogLevel::ERROR, $message, $context); |
|
70 | - } |
|
58 | + /** |
|
59 | + * Runtime errors that do not require immediate action but should typically |
|
60 | + * be logged and monitored. |
|
61 | + * |
|
62 | + * @param string $message |
|
63 | + * @param mixed[] $context |
|
64 | + * |
|
65 | + * @return void |
|
66 | + */ |
|
67 | + public function error($message, array $context = array()) |
|
68 | + { |
|
69 | + $this->log(LogLevel::ERROR, $message, $context); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Exceptional occurrences that are not errors. |
|
74 | - * |
|
75 | - * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
76 | - * that are not necessarily wrong. |
|
77 | - * |
|
78 | - * @param string $message |
|
79 | - * @param mixed[] $context |
|
80 | - * |
|
81 | - * @return void |
|
82 | - */ |
|
83 | - public function warning($message, array $context = array()) |
|
84 | - { |
|
85 | - $this->log(LogLevel::WARNING, $message, $context); |
|
86 | - } |
|
72 | + /** |
|
73 | + * Exceptional occurrences that are not errors. |
|
74 | + * |
|
75 | + * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
76 | + * that are not necessarily wrong. |
|
77 | + * |
|
78 | + * @param string $message |
|
79 | + * @param mixed[] $context |
|
80 | + * |
|
81 | + * @return void |
|
82 | + */ |
|
83 | + public function warning($message, array $context = array()) |
|
84 | + { |
|
85 | + $this->log(LogLevel::WARNING, $message, $context); |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * Normal but significant events. |
|
90 | - * |
|
91 | - * @param string $message |
|
92 | - * @param mixed[] $context |
|
93 | - * |
|
94 | - * @return void |
|
95 | - */ |
|
96 | - public function notice($message, array $context = array()) |
|
97 | - { |
|
98 | - $this->log(LogLevel::NOTICE, $message, $context); |
|
99 | - } |
|
88 | + /** |
|
89 | + * Normal but significant events. |
|
90 | + * |
|
91 | + * @param string $message |
|
92 | + * @param mixed[] $context |
|
93 | + * |
|
94 | + * @return void |
|
95 | + */ |
|
96 | + public function notice($message, array $context = array()) |
|
97 | + { |
|
98 | + $this->log(LogLevel::NOTICE, $message, $context); |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Interesting events. |
|
103 | - * |
|
104 | - * Example: User logs in, SQL logs. |
|
105 | - * |
|
106 | - * @param string $message |
|
107 | - * @param mixed[] $context |
|
108 | - * |
|
109 | - * @return void |
|
110 | - */ |
|
111 | - public function info($message, array $context = array()) |
|
112 | - { |
|
113 | - $this->log(LogLevel::INFO, $message, $context); |
|
114 | - } |
|
101 | + /** |
|
102 | + * Interesting events. |
|
103 | + * |
|
104 | + * Example: User logs in, SQL logs. |
|
105 | + * |
|
106 | + * @param string $message |
|
107 | + * @param mixed[] $context |
|
108 | + * |
|
109 | + * @return void |
|
110 | + */ |
|
111 | + public function info($message, array $context = array()) |
|
112 | + { |
|
113 | + $this->log(LogLevel::INFO, $message, $context); |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * Detailed debug information. |
|
118 | - * |
|
119 | - * @param string $message |
|
120 | - * @param mixed[] $context |
|
121 | - * |
|
122 | - * @return void |
|
123 | - */ |
|
124 | - public function debug($message, array $context = array()) |
|
125 | - { |
|
126 | - $this->log(LogLevel::DEBUG, $message, $context); |
|
127 | - } |
|
116 | + /** |
|
117 | + * Detailed debug information. |
|
118 | + * |
|
119 | + * @param string $message |
|
120 | + * @param mixed[] $context |
|
121 | + * |
|
122 | + * @return void |
|
123 | + */ |
|
124 | + public function debug($message, array $context = array()) |
|
125 | + { |
|
126 | + $this->log(LogLevel::DEBUG, $message, $context); |
|
127 | + } |
|
128 | 128 | } |
@@ -9,8 +9,7 @@ |
||
9 | 9 | * reduce boilerplate code that a simple Logger that does the same thing with |
10 | 10 | * messages regardless of the error level has to implement. |
11 | 11 | */ |
12 | -abstract class AbstractLogger implements LoggerInterface |
|
13 | -{ |
|
12 | +abstract class AbstractLogger implements LoggerInterface { |
|
14 | 13 | /** |
15 | 14 | * System is unusable. |
16 | 15 | * |
@@ -7,20 +7,20 @@ |
||
7 | 7 | */ |
8 | 8 | trait LoggerAwareTrait |
9 | 9 | { |
10 | - /** |
|
11 | - * The logger instance. |
|
12 | - * |
|
13 | - * @var LoggerInterface|null |
|
14 | - */ |
|
15 | - protected $logger; |
|
10 | + /** |
|
11 | + * The logger instance. |
|
12 | + * |
|
13 | + * @var LoggerInterface|null |
|
14 | + */ |
|
15 | + protected $logger; |
|
16 | 16 | |
17 | - /** |
|
18 | - * Sets a logger. |
|
19 | - * |
|
20 | - * @param LoggerInterface $logger |
|
21 | - */ |
|
22 | - public function setLogger(LoggerInterface $logger) |
|
23 | - { |
|
24 | - $this->logger = $logger; |
|
25 | - } |
|
17 | + /** |
|
18 | + * Sets a logger. |
|
19 | + * |
|
20 | + * @param LoggerInterface $logger |
|
21 | + */ |
|
22 | + public function setLogger(LoggerInterface $logger) |
|
23 | + { |
|
24 | + $this->logger = $logger; |
|
25 | + } |
|
26 | 26 | } |
@@ -5,8 +5,7 @@ |
||
5 | 5 | /** |
6 | 6 | * Basic Implementation of LoggerAwareInterface. |
7 | 7 | */ |
8 | -trait LoggerAwareTrait |
|
9 | -{ |
|
8 | +trait LoggerAwareTrait { |
|
10 | 9 | /** |
11 | 10 | * The logger instance. |
12 | 11 | * |
@@ -56,92 +56,92 @@ |
||
56 | 56 | */ |
57 | 57 | class TestLogger extends AbstractLogger |
58 | 58 | { |
59 | - /** |
|
60 | - * @var array |
|
61 | - */ |
|
62 | - public $records = []; |
|
59 | + /** |
|
60 | + * @var array |
|
61 | + */ |
|
62 | + public $records = []; |
|
63 | 63 | |
64 | - public $recordsByLevel = []; |
|
64 | + public $recordsByLevel = []; |
|
65 | 65 | |
66 | - /** |
|
67 | - * @inheritdoc |
|
68 | - */ |
|
69 | - public function log($level, $message, array $context = []) |
|
70 | - { |
|
71 | - $record = [ |
|
72 | - 'level' => $level, |
|
73 | - 'message' => $message, |
|
74 | - 'context' => $context, |
|
75 | - ]; |
|
66 | + /** |
|
67 | + * @inheritdoc |
|
68 | + */ |
|
69 | + public function log($level, $message, array $context = []) |
|
70 | + { |
|
71 | + $record = [ |
|
72 | + 'level' => $level, |
|
73 | + 'message' => $message, |
|
74 | + 'context' => $context, |
|
75 | + ]; |
|
76 | 76 | |
77 | - $this->recordsByLevel[$record['level']][] = $record; |
|
78 | - $this->records[] = $record; |
|
79 | - } |
|
77 | + $this->recordsByLevel[$record['level']][] = $record; |
|
78 | + $this->records[] = $record; |
|
79 | + } |
|
80 | 80 | |
81 | - public function hasRecords($level) |
|
82 | - { |
|
83 | - return isset($this->recordsByLevel[$level]); |
|
84 | - } |
|
81 | + public function hasRecords($level) |
|
82 | + { |
|
83 | + return isset($this->recordsByLevel[$level]); |
|
84 | + } |
|
85 | 85 | |
86 | - public function hasRecord($record, $level) |
|
87 | - { |
|
88 | - if (is_string($record)) { |
|
89 | - $record = ['message' => $record]; |
|
90 | - } |
|
91 | - return $this->hasRecordThatPasses(function ($rec) use ($record) { |
|
92 | - if ($rec['message'] !== $record['message']) { |
|
93 | - return false; |
|
94 | - } |
|
95 | - if (isset($record['context']) && $rec['context'] !== $record['context']) { |
|
96 | - return false; |
|
97 | - } |
|
98 | - return true; |
|
99 | - }, $level); |
|
100 | - } |
|
86 | + public function hasRecord($record, $level) |
|
87 | + { |
|
88 | + if (is_string($record)) { |
|
89 | + $record = ['message' => $record]; |
|
90 | + } |
|
91 | + return $this->hasRecordThatPasses(function ($rec) use ($record) { |
|
92 | + if ($rec['message'] !== $record['message']) { |
|
93 | + return false; |
|
94 | + } |
|
95 | + if (isset($record['context']) && $rec['context'] !== $record['context']) { |
|
96 | + return false; |
|
97 | + } |
|
98 | + return true; |
|
99 | + }, $level); |
|
100 | + } |
|
101 | 101 | |
102 | - public function hasRecordThatContains($message, $level) |
|
103 | - { |
|
104 | - return $this->hasRecordThatPasses(function ($rec) use ($message) { |
|
105 | - return strpos($rec['message'], $message) !== false; |
|
106 | - }, $level); |
|
107 | - } |
|
102 | + public function hasRecordThatContains($message, $level) |
|
103 | + { |
|
104 | + return $this->hasRecordThatPasses(function ($rec) use ($message) { |
|
105 | + return strpos($rec['message'], $message) !== false; |
|
106 | + }, $level); |
|
107 | + } |
|
108 | 108 | |
109 | - public function hasRecordThatMatches($regex, $level) |
|
110 | - { |
|
111 | - return $this->hasRecordThatPasses(function ($rec) use ($regex) { |
|
112 | - return preg_match($regex, $rec['message']) > 0; |
|
113 | - }, $level); |
|
114 | - } |
|
109 | + public function hasRecordThatMatches($regex, $level) |
|
110 | + { |
|
111 | + return $this->hasRecordThatPasses(function ($rec) use ($regex) { |
|
112 | + return preg_match($regex, $rec['message']) > 0; |
|
113 | + }, $level); |
|
114 | + } |
|
115 | 115 | |
116 | - public function hasRecordThatPasses(callable $predicate, $level) |
|
117 | - { |
|
118 | - if (!isset($this->recordsByLevel[$level])) { |
|
119 | - return false; |
|
120 | - } |
|
121 | - foreach ($this->recordsByLevel[$level] as $i => $rec) { |
|
122 | - if (call_user_func($predicate, $rec, $i)) { |
|
123 | - return true; |
|
124 | - } |
|
125 | - } |
|
126 | - return false; |
|
127 | - } |
|
116 | + public function hasRecordThatPasses(callable $predicate, $level) |
|
117 | + { |
|
118 | + if (!isset($this->recordsByLevel[$level])) { |
|
119 | + return false; |
|
120 | + } |
|
121 | + foreach ($this->recordsByLevel[$level] as $i => $rec) { |
|
122 | + if (call_user_func($predicate, $rec, $i)) { |
|
123 | + return true; |
|
124 | + } |
|
125 | + } |
|
126 | + return false; |
|
127 | + } |
|
128 | 128 | |
129 | - public function __call($method, $args) |
|
130 | - { |
|
131 | - if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) { |
|
132 | - $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3]; |
|
133 | - $level = strtolower($matches[2]); |
|
134 | - if (method_exists($this, $genericMethod)) { |
|
135 | - $args[] = $level; |
|
136 | - return call_user_func_array([$this, $genericMethod], $args); |
|
137 | - } |
|
138 | - } |
|
139 | - throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()'); |
|
140 | - } |
|
129 | + public function __call($method, $args) |
|
130 | + { |
|
131 | + if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) { |
|
132 | + $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3]; |
|
133 | + $level = strtolower($matches[2]); |
|
134 | + if (method_exists($this, $genericMethod)) { |
|
135 | + $args[] = $level; |
|
136 | + return call_user_func_array([$this, $genericMethod], $args); |
|
137 | + } |
|
138 | + } |
|
139 | + throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()'); |
|
140 | + } |
|
141 | 141 | |
142 | - public function reset() |
|
143 | - { |
|
144 | - $this->records = []; |
|
145 | - $this->recordsByLevel = []; |
|
146 | - } |
|
142 | + public function reset() |
|
143 | + { |
|
144 | + $this->records = []; |
|
145 | + $this->recordsByLevel = []; |
|
146 | + } |
|
147 | 147 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | if (is_string($record)) { |
89 | 89 | $record = ['message' => $record]; |
90 | 90 | } |
91 | - return $this->hasRecordThatPasses(function ($rec) use ($record) { |
|
91 | + return $this->hasRecordThatPasses(function($rec) use ($record) { |
|
92 | 92 | if ($rec['message'] !== $record['message']) { |
93 | 93 | return false; |
94 | 94 | } |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | |
102 | 102 | public function hasRecordThatContains($message, $level) |
103 | 103 | { |
104 | - return $this->hasRecordThatPasses(function ($rec) use ($message) { |
|
104 | + return $this->hasRecordThatPasses(function($rec) use ($message) { |
|
105 | 105 | return strpos($rec['message'], $message) !== false; |
106 | 106 | }, $level); |
107 | 107 | } |
108 | 108 | |
109 | 109 | public function hasRecordThatMatches($regex, $level) |
110 | 110 | { |
111 | - return $this->hasRecordThatPasses(function ($rec) use ($regex) { |
|
111 | + return $this->hasRecordThatPasses(function($rec) use ($regex) { |
|
112 | 112 | return preg_match($regex, $rec['message']) > 0; |
113 | 113 | }, $level); |
114 | 114 | } |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | public function __call($method, $args) |
130 | 130 | { |
131 | 131 | if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) { |
132 | - $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3]; |
|
132 | + $genericMethod = $matches[1].('Records' !== $matches[3] ? 'Record' : '').$matches[3]; |
|
133 | 133 | $level = strtolower($matches[2]); |
134 | 134 | if (method_exists($this, $genericMethod)) { |
135 | 135 | $args[] = $level; |
136 | 136 | return call_user_func_array([$this, $genericMethod], $args); |
137 | 137 | } |
138 | 138 | } |
139 | - throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()'); |
|
139 | + throw new \BadMethodCallException('Call to undefined method '.get_class($this).'::'.$method.'()'); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | public function reset() |
@@ -54,8 +54,7 @@ |
||
54 | 54 | * @method bool hasInfoThatPasses($message) |
55 | 55 | * @method bool hasDebugThatPasses($message) |
56 | 56 | */ |
57 | -class TestLogger extends AbstractLogger |
|
58 | -{ |
|
57 | +class TestLogger extends AbstractLogger { |
|
59 | 58 | /** |
60 | 59 | * @var array |
61 | 60 | */ |
@@ -14,125 +14,125 @@ |
||
14 | 14 | */ |
15 | 15 | abstract class LoggerInterfaceTest extends TestCase |
16 | 16 | { |
17 | - /** |
|
18 | - * @return LoggerInterface |
|
19 | - */ |
|
20 | - abstract public function getLogger(); |
|
21 | - |
|
22 | - /** |
|
23 | - * This must return the log messages in order. |
|
24 | - * |
|
25 | - * The simple formatting of the messages is: "<LOG LEVEL> <MESSAGE>". |
|
26 | - * |
|
27 | - * Example ->error('Foo') would yield "error Foo". |
|
28 | - * |
|
29 | - * @return string[] |
|
30 | - */ |
|
31 | - abstract public function getLogs(); |
|
32 | - |
|
33 | - public function testImplements() |
|
34 | - { |
|
35 | - $this->assertInstanceOf('OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Log\LoggerInterface', $this->getLogger()); |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * @dataProvider provideLevelsAndMessages |
|
40 | - */ |
|
41 | - public function testLogsAtAllLevels($level, $message) |
|
42 | - { |
|
43 | - $logger = $this->getLogger(); |
|
44 | - $logger->{$level}($message, array('user' => 'Bob')); |
|
45 | - $logger->log($level, $message, array('user' => 'Bob')); |
|
46 | - |
|
47 | - $expected = array( |
|
48 | - $level.' message of level '.$level.' with context: Bob', |
|
49 | - $level.' message of level '.$level.' with context: Bob', |
|
50 | - ); |
|
51 | - $this->assertEquals($expected, $this->getLogs()); |
|
52 | - } |
|
53 | - |
|
54 | - public function provideLevelsAndMessages() |
|
55 | - { |
|
56 | - return array( |
|
57 | - LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'), |
|
58 | - LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'), |
|
59 | - LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'), |
|
60 | - LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'), |
|
61 | - LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'), |
|
62 | - LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'), |
|
63 | - LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'), |
|
64 | - LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'), |
|
65 | - ); |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * @expectedException \OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Log\InvalidArgumentException |
|
70 | - */ |
|
71 | - public function testThrowsOnInvalidLevel() |
|
72 | - { |
|
73 | - $logger = $this->getLogger(); |
|
74 | - $logger->log('invalid level', 'Foo'); |
|
75 | - } |
|
76 | - |
|
77 | - public function testContextReplacement() |
|
78 | - { |
|
79 | - $logger = $this->getLogger(); |
|
80 | - $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar')); |
|
81 | - |
|
82 | - $expected = array('info {Message {nothing} Bob Bar a}'); |
|
83 | - $this->assertEquals($expected, $this->getLogs()); |
|
84 | - } |
|
85 | - |
|
86 | - public function testObjectCastToString() |
|
87 | - { |
|
88 | - if (method_exists($this, 'createPartialMock')) { |
|
89 | - $dummy = $this->createPartialMock('OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Log\Test\DummyTest', array('__toString')); |
|
90 | - } else { |
|
91 | - $dummy = $this->getMock('OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Log\Test\DummyTest', array('__toString')); |
|
92 | - } |
|
93 | - $dummy->expects($this->once()) |
|
94 | - ->method('__toString') |
|
95 | - ->will($this->returnValue('DUMMY')); |
|
96 | - |
|
97 | - $this->getLogger()->warning($dummy); |
|
98 | - |
|
99 | - $expected = array('warning DUMMY'); |
|
100 | - $this->assertEquals($expected, $this->getLogs()); |
|
101 | - } |
|
102 | - |
|
103 | - public function testContextCanContainAnything() |
|
104 | - { |
|
105 | - $closed = fopen('php://memory', 'r'); |
|
106 | - fclose($closed); |
|
107 | - |
|
108 | - $context = array( |
|
109 | - 'bool' => true, |
|
110 | - 'null' => null, |
|
111 | - 'string' => 'Foo', |
|
112 | - 'int' => 0, |
|
113 | - 'float' => 0.5, |
|
114 | - 'nested' => array('with object' => new DummyTest), |
|
115 | - 'object' => new \DateTime, |
|
116 | - 'resource' => fopen('php://memory', 'r'), |
|
117 | - 'closed' => $closed, |
|
118 | - ); |
|
119 | - |
|
120 | - $this->getLogger()->warning('Crazy context data', $context); |
|
121 | - |
|
122 | - $expected = array('warning Crazy context data'); |
|
123 | - $this->assertEquals($expected, $this->getLogs()); |
|
124 | - } |
|
125 | - |
|
126 | - public function testContextExceptionKeyCanBeExceptionOrOtherValues() |
|
127 | - { |
|
128 | - $logger = $this->getLogger(); |
|
129 | - $logger->warning('Random message', array('exception' => 'oops')); |
|
130 | - $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail'))); |
|
131 | - |
|
132 | - $expected = array( |
|
133 | - 'warning Random message', |
|
134 | - 'critical Uncaught Exception!' |
|
135 | - ); |
|
136 | - $this->assertEquals($expected, $this->getLogs()); |
|
137 | - } |
|
17 | + /** |
|
18 | + * @return LoggerInterface |
|
19 | + */ |
|
20 | + abstract public function getLogger(); |
|
21 | + |
|
22 | + /** |
|
23 | + * This must return the log messages in order. |
|
24 | + * |
|
25 | + * The simple formatting of the messages is: "<LOG LEVEL> <MESSAGE>". |
|
26 | + * |
|
27 | + * Example ->error('Foo') would yield "error Foo". |
|
28 | + * |
|
29 | + * @return string[] |
|
30 | + */ |
|
31 | + abstract public function getLogs(); |
|
32 | + |
|
33 | + public function testImplements() |
|
34 | + { |
|
35 | + $this->assertInstanceOf('OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Log\LoggerInterface', $this->getLogger()); |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * @dataProvider provideLevelsAndMessages |
|
40 | + */ |
|
41 | + public function testLogsAtAllLevels($level, $message) |
|
42 | + { |
|
43 | + $logger = $this->getLogger(); |
|
44 | + $logger->{$level}($message, array('user' => 'Bob')); |
|
45 | + $logger->log($level, $message, array('user' => 'Bob')); |
|
46 | + |
|
47 | + $expected = array( |
|
48 | + $level.' message of level '.$level.' with context: Bob', |
|
49 | + $level.' message of level '.$level.' with context: Bob', |
|
50 | + ); |
|
51 | + $this->assertEquals($expected, $this->getLogs()); |
|
52 | + } |
|
53 | + |
|
54 | + public function provideLevelsAndMessages() |
|
55 | + { |
|
56 | + return array( |
|
57 | + LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'), |
|
58 | + LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'), |
|
59 | + LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'), |
|
60 | + LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'), |
|
61 | + LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'), |
|
62 | + LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'), |
|
63 | + LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'), |
|
64 | + LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'), |
|
65 | + ); |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * @expectedException \OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Log\InvalidArgumentException |
|
70 | + */ |
|
71 | + public function testThrowsOnInvalidLevel() |
|
72 | + { |
|
73 | + $logger = $this->getLogger(); |
|
74 | + $logger->log('invalid level', 'Foo'); |
|
75 | + } |
|
76 | + |
|
77 | + public function testContextReplacement() |
|
78 | + { |
|
79 | + $logger = $this->getLogger(); |
|
80 | + $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar')); |
|
81 | + |
|
82 | + $expected = array('info {Message {nothing} Bob Bar a}'); |
|
83 | + $this->assertEquals($expected, $this->getLogs()); |
|
84 | + } |
|
85 | + |
|
86 | + public function testObjectCastToString() |
|
87 | + { |
|
88 | + if (method_exists($this, 'createPartialMock')) { |
|
89 | + $dummy = $this->createPartialMock('OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Log\Test\DummyTest', array('__toString')); |
|
90 | + } else { |
|
91 | + $dummy = $this->getMock('OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Log\Test\DummyTest', array('__toString')); |
|
92 | + } |
|
93 | + $dummy->expects($this->once()) |
|
94 | + ->method('__toString') |
|
95 | + ->will($this->returnValue('DUMMY')); |
|
96 | + |
|
97 | + $this->getLogger()->warning($dummy); |
|
98 | + |
|
99 | + $expected = array('warning DUMMY'); |
|
100 | + $this->assertEquals($expected, $this->getLogs()); |
|
101 | + } |
|
102 | + |
|
103 | + public function testContextCanContainAnything() |
|
104 | + { |
|
105 | + $closed = fopen('php://memory', 'r'); |
|
106 | + fclose($closed); |
|
107 | + |
|
108 | + $context = array( |
|
109 | + 'bool' => true, |
|
110 | + 'null' => null, |
|
111 | + 'string' => 'Foo', |
|
112 | + 'int' => 0, |
|
113 | + 'float' => 0.5, |
|
114 | + 'nested' => array('with object' => new DummyTest), |
|
115 | + 'object' => new \DateTime, |
|
116 | + 'resource' => fopen('php://memory', 'r'), |
|
117 | + 'closed' => $closed, |
|
118 | + ); |
|
119 | + |
|
120 | + $this->getLogger()->warning('Crazy context data', $context); |
|
121 | + |
|
122 | + $expected = array('warning Crazy context data'); |
|
123 | + $this->assertEquals($expected, $this->getLogs()); |
|
124 | + } |
|
125 | + |
|
126 | + public function testContextExceptionKeyCanBeExceptionOrOtherValues() |
|
127 | + { |
|
128 | + $logger = $this->getLogger(); |
|
129 | + $logger->warning('Random message', array('exception' => 'oops')); |
|
130 | + $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail'))); |
|
131 | + |
|
132 | + $expected = array( |
|
133 | + 'warning Random message', |
|
134 | + 'critical Uncaught Exception!' |
|
135 | + ); |
|
136 | + $this->assertEquals($expected, $this->getLogs()); |
|
137 | + } |
|
138 | 138 | } |
@@ -12,8 +12,7 @@ |
||
12 | 12 | * Implementors can extend the class and implement abstract methods to run this |
13 | 13 | * as part of their test suite. |
14 | 14 | */ |
15 | -abstract class LoggerInterfaceTest extends TestCase |
|
16 | -{ |
|
15 | +abstract class LoggerInterfaceTest extends TestCase { |
|
17 | 16 | /** |
18 | 17 | * @return LoggerInterface |
19 | 18 | */ |
@@ -11,8 +11,8 @@ |
||
11 | 11 | */ |
12 | 12 | class DummyTest |
13 | 13 | { |
14 | - public function __toString() |
|
15 | - { |
|
16 | - return 'DummyTest'; |
|
17 | - } |
|
14 | + public function __toString() |
|
15 | + { |
|
16 | + return 'DummyTest'; |
|
17 | + } |
|
18 | 18 | } |
@@ -9,8 +9,7 @@ |
||
9 | 9 | * |
10 | 10 | * @internal |
11 | 11 | */ |
12 | -class DummyTest |
|
13 | -{ |
|
12 | +class DummyTest { |
|
14 | 13 | public function __toString() |
15 | 14 | { |
16 | 15 | return 'DummyTest'; |
@@ -12,19 +12,19 @@ |
||
12 | 12 | */ |
13 | 13 | class NullLogger extends AbstractLogger |
14 | 14 | { |
15 | - /** |
|
16 | - * Logs with an arbitrary level. |
|
17 | - * |
|
18 | - * @param mixed $level |
|
19 | - * @param string $message |
|
20 | - * @param array $context |
|
21 | - * |
|
22 | - * @return void |
|
23 | - * |
|
24 | - * @throws \OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Log\InvalidArgumentException |
|
25 | - */ |
|
26 | - public function log($level, $message, array $context = array()) |
|
27 | - { |
|
28 | - // noop |
|
29 | - } |
|
15 | + /** |
|
16 | + * Logs with an arbitrary level. |
|
17 | + * |
|
18 | + * @param mixed $level |
|
19 | + * @param string $message |
|
20 | + * @param array $context |
|
21 | + * |
|
22 | + * @return void |
|
23 | + * |
|
24 | + * @throws \OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Log\InvalidArgumentException |
|
25 | + */ |
|
26 | + public function log($level, $message, array $context = array()) |
|
27 | + { |
|
28 | + // noop |
|
29 | + } |
|
30 | 30 | } |
@@ -10,8 +10,7 @@ |
||
10 | 10 | * is a good way to avoid littering your code with `if ($this->logger) { }` |
11 | 11 | * blocks. |
12 | 12 | */ |
13 | -class NullLogger extends AbstractLogger |
|
14 | -{ |
|
13 | +class NullLogger extends AbstractLogger { |
|
15 | 14 | /** |
16 | 15 | * Logs with an arbitrary level. |
17 | 16 | * |