1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
16:
17: 18: 19: 20: 21: 22: 23: 24:
25: class Horde_Log_Formatter_Xml implements Horde_Log_Formatter
26: {
27: 28: 29: 30: 31:
32: protected $_options = array(
33: 'elementEntry' => 'log',
34: 'elementTimestamp' => 'timestamp',
35: 'elementMessage' => 'message',
36: 'elementLevel' => 'level',
37: 'lineEnding' => PHP_EOL
38: );
39:
40: 41: 42: 43: 44:
45: public function __construct($options = array())
46: {
47: $this->_options = array_merge($this->_options, $options);
48: }
49:
50: 51: 52: 53: 54: 55: 56:
57: public function format($event)
58: {
59: $dom = new DOMDocument();
60:
61: $elt = $dom->appendChild(new DOMElement($this->_options['elementEntry']));
62: $elt->appendChild(new DOMElement($this->_options['elementTimestamp'], date('c')));
63: $elt->appendChild(new DOMElement($this->_options['elementMessage'], $event['message']));
64: $elt->appendChild(new DOMElement($this->_options['elementLevel'], $event['level']));
65:
66: return preg_replace('/<\?xml version="1.0"( encoding="[^\"]*")?\?>\n/u', '', $dom->saveXML()) . $this->_options['lineEnding'];
67: }
68:
69: }
70: