1 <?php
2 3 4 5 6 7
8 if (!empty($message)) {
9
10 $trace = &$message['trace'];
11 $table = &$message['trace_table'];
12 $previous_trace = &$message['previous_trace'];
13
14 15 16
17 if (!function_exists('ascLogo')) {
18 function ascLogo($txtTableInfo)
19 {
20 $line_width = array_sum($txtTableInfo) + count($txtTableInfo) + 1;
21 $asc_logo_data = <<<ASC_LOGO
22 __ v%s
23 ______________ ______________ / /_ ____
24 / ___/ ___/ __ \/ ___/ ___/ __ \/ __ \/ __ \
25 / /__/ / / /_/ (__ )__ ) /_/ / / / / /_/ /
26 \___/_/ \____/____/____/ .___/_/ /_/ .___/
27 /_/ /_/
28 ASC_LOGO;
29
30 $logo_lines = explode("\n", sprintf($asc_logo_data, \Cross\Core\Delegate::getVersion()));
31 $offset = 6;
32 $max_width = 0;
33 foreach ($logo_lines as $line) {
34 $length = strlen($line);
35 if ($length > $max_width) {
36 $max_width = $length;
37 }
38 }
39
40 $half_width = floor($line_width / 2 - ($max_width - $offset) / 2);
41 foreach ($logo_lines as $line) {
42 for ($i = 0; $i <= $line_width; $i++) {
43 if ($i == $half_width) {
44 echo $line;
45 } elseif ($i < $half_width) {
46 echo ' ';
47 }
48 }
49 echo PHP_EOL;
50 }
51 echo PHP_EOL;
52 }
53 }
54
55 56 57 58 59 60 61
62 if (!function_exists('line')) {
63 function line($txtTableInfo, $text = '', $pad_string = '=')
64 {
65 $text_length = 0;
66 if (!empty($text)) {
67 $text_length = strlen($text);
68 }
69
70 $line_width = array_sum($txtTableInfo) + count($txtTableInfo) + 1;
71 $s = floor($line_width / 2 - $text_length / 2);
72 for ($i = 0; $i < $line_width; $i++) {
73 if ($i == $s) {
74 echo $text;
75 $i += $text_length;
76 }
77 echo $pad_string;
78 }
79 echo PHP_EOL;
80 }
81 }
82
83 84 85 86 87
88 if (!function_exists('th')) {
89 function th($txtTableInfo)
90 {
91 echo '+';
92 foreach ($txtTableInfo as $type_name => $line_width) {
93 for ($i = 0; $i < $line_width; $i++) {
94 echo '-';
95 }
96 echo '+';
97 }
98 echo PHP_EOL;
99 }
100 }
101
102 103 104 105 106
107 if (!function_exists('tHead')) {
108 function tHead($txtTableInfo)
109 {
110 echo '|';
111 foreach ($txtTableInfo as $type_name => $line_width) {
112 $name_width = strlen($type_name);
113 $name_offset = floor($line_width / 2 - $name_width / 2) + 1;
114
115 $i = 0;
116 while ($i++ < $line_width) {
117 if ($i == $name_offset) {
118 echo ucfirst($type_name);
119 $i += $name_width - 1;
120 } else {
121 echo ' ';
122 }
123 }
124 echo '|';
125 }
126 echo PHP_EOL;
127 }
128 }
129
130 131 132 133 134 135
136 if (!function_exists('tBody')) {
137 function tBody($data, $txtTableInfo)
138 {
139 echo '|';
140 foreach ($txtTableInfo as $type => $line_width) {
141 $content_length = strlen($data[$type]);
142 $i = 0;
143 while ($i++ < $line_width) {
144 if ($i == 2) {
145 echo $data[$type];
146 $i += $content_length - 1;
147 } else {
148 echo ' ';
149 }
150 }
151 echo '|';
152 }
153 echo PHP_EOL;
154 }
155 }
156
157 echo PHP_EOL;
158 ascLogo($table);
159 line($table, '-- Exception Start --');
160 printf("\n Message: %s \n File: %s Line: %s \n\n", $message['message'], $message['file'], $message['line']);
161
162 th($table);
163 thead($table);
164 th($table);
165
166 if (!empty($trace)) {
167 foreach ($trace as $t) {
168 tBody($t, $table);
169 }
170 th($table);
171 }
172
173 if (!empty($previous_trace)) {
174 line($table, 'Previous Trace', ' ');
175 th($table);
176 foreach ($previous_trace as $t) {
177 tBody($t, $table);
178 }
179 th($table);
180 }
181
182 echo PHP_EOL;
183 line($table, sprintf("-- Exception END %s --", date('Y-m-d H:i:s', time())));
184 }
185
186
187