3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Log\Formatter
;
14 class ExceptionHandler
implements FormatterInterface
17 * Format specifier for DateTime objects in event data
19 * @see http://php.net/manual/en/function.date.php
22 protected $dateTimeFormat = self
::DEFAULT_DATETIME_FORMAT
;
25 * This method formats the event for the PHP Exception
30 public function format($event)
32 if (isset($event['timestamp']) && $event['timestamp'] instanceof DateTime
) {
33 $event['timestamp'] = $event['timestamp']->format($this->getDateTimeFormat());
36 $output = $event['timestamp'] . ' ' . $event['priorityName'] . ' ('
37 . $event['priority'] . ') ' . $event['message'] .' in '
38 . $event['extra']['file'] . ' on line ' . $event['extra']['line'];
40 if (!empty($event['extra']['trace'])) {
42 foreach ($event['extra']['trace'] as $trace) {
43 $outputTrace .= "File : {$trace['file']}\n"
44 . "Line : {$trace['line']}\n"
45 . "Func : {$trace['function']}\n"
46 . "Class : {$trace['class']}\n"
47 . "Type : " . $this->getType($trace['type']) . "\n"
48 . "Args : " . print_r($trace['args'], true) . "\n";
50 $output .= "\n[Trace]\n" . $outputTrace;
59 public function getDateTimeFormat()
61 return $this->dateTimeFormat
;
67 public function setDateTimeFormat($dateTimeFormat)
69 $this->dateTimeFormat
= (string) $dateTimeFormat;
74 * Get the type of a function
79 protected function getType($type)