Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Log / Formatter / ExceptionHandler.php
blobd1fb46988ee217802f05c882ee363a113ebd91d2
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Log\Formatter;
12 use DateTime;
14 class ExceptionHandler implements FormatterInterface
16 /**
17 * Format specifier for DateTime objects in event data
19 * @see http://php.net/manual/en/function.date.php
20 * @var string
22 protected $dateTimeFormat = self::DEFAULT_DATETIME_FORMAT;
24 /**
25 * This method formats the event for the PHP Exception
27 * @param array $event
28 * @return string
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'])) {
41 $outputTrace = '';
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;
53 return $output;
56 /**
57 * {@inheritDoc}
59 public function getDateTimeFormat()
61 return $this->dateTimeFormat;
64 /**
65 * {@inheritDoc}
67 public function setDateTimeFormat($dateTimeFormat)
69 $this->dateTimeFormat = (string) $dateTimeFormat;
70 return $this;
73 /**
74 * Get the type of a function
76 * @param string $type
77 * @return string
79 protected function getType($type)
81 switch ($type) {
82 case "::" :
83 return "static";
84 case "->" :
85 return "method";
86 default :
87 return $type;