@@ -7,17 +7,32 @@ class EngineBlock_Log_Writer_Syslog_MessageParser
77 */
88 public function parse (array $ event )
99 {
10- $ message = isset ($ event ['message ' ])
11- ? $ this ->_normalizeMessage ($ event ['message ' ]) : '' ;
10+ $ message = isset ($ event ['message ' ]) ? $ this ->_normalizeMessage ($ event ['message ' ]) : '' ;
1211
1312 preg_match_all (
14- '/([^\]]*\[[a-zA-Z0-9 ]+\]\[[a-zA-Z0-9 ]+\](\[DUMP[^\]]*\])?)( .*)/ ' ,
15- $ message , $ matches
13+ '/ ' .
14+ '( ' .
15+ '[^\]]* ' . // .... (anything but a ]), followed by:
16+ '\[[a-zA-Z0-9 ]+\] ' . // [ ... ]
17+ '\[[a-zA-Z0-9 ]+\] ' . // [ ... ]
18+ '(\[DUMP[^\]]*\])? ' . // Optionally: [DUMP ...]
19+ ') ' .
20+ '( .*) ' . // Anything, starting with a space.
21+ '/ ' ,
22+ $ message ,
23+ $ matches
1624 );
1725
26+ if (!isset ($ matches [1 ][0 ]) || !isset ($ matches [3 ][0 ])) {
27+ return array (
28+ 'prefix ' => 'P[ ' . time () . '][ ' . rand (0 , 1000000 ) . '] ' ,
29+ 'message ' => $ message
30+ );
31+ }
32+
1833 return array (
19- 'prefix ' => isset ( $ matches [1 ][0 ]) ? $ matches [ 1 ][ 0 ] : ' PREFIX REMOVED BY PARSER ' ,
20- 'message ' => isset ( $ matches [3 ][0 ]) ? $ matches [ 3 ][ 0 ] : ' MESSAGE REMOVED BY PARSER ' ,
34+ 'prefix ' => $ matches [1 ][0 ],
35+ 'message ' => $ matches [3 ][0 ],
2136 );
2237 }
2338
@@ -30,7 +45,7 @@ public function parse(array $event)
3045 * Serialized content is prepended with '!FORMAT_[type]', this
3146 * notation is parsed by logparse.sh
3247 *
33- * @param mixed data structure to dump
48+ * @param string $message structure to dump
3449 * @return string
3550 */
3651 protected function _normalizeMessage ($ message )
0 commit comments