@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class DarkConsoleErrorLogPlugin extends DarkConsolePlugin {
4
5 public function getName() {
6 $count = count($this->getData());
7 if ($count) {
8 return pht('Error Log (%d)', $count);
9 }
10 return pht('Error Log');
11 }
12
13 public function getOrder() {
14 return 0;
15 }
16
17 public function getColor() {
18 if (count($this->getData())) {
19 return '#ff0000';
20 }
21 return null;
22 }
23
24 public function getDescription() {
25 return pht('Shows errors and warnings.');
26 }
27
28 public function generateData() {
29 return DarkConsoleErrorLogPluginAPI::getErrors();
30 }
31
32 public function renderPanel() {
33 $data = $this->getData();
34
35 $rows = array();
36 $details = array();
37
38 foreach ($data as $index => $row) {
39 $file = $row['file'];
40 $line = $row['line'];
41
42 $tag = javelin_tag(
43 'a',
44 array(
45 'sigil' => 'darkconsole-expand',
46 'meta' => array(
47 'expandID' => 'row-details-'.$index,
48 ),
49 ),
50 $row['str'].' at ['.basename($file).':'.$line.']');
51 $rows[] = array($tag);
52
53 $details[] = hsprintf(
54 '<div class="dark-console-panel-error-details" id="row-details-%s">'.
55 "%s\nStack trace:\n",
56 $index,
57 $row['details']);
58
59 foreach ($row['trace'] as $key => $entry) {
60 $line = '';
61 if (isset($entry['class'])) {
62 $line .= $entry['class'].'::';
63 }
64 $line .= idx($entry, 'function', '');
65 $href = null;
66 if (isset($entry['file'])) {
67 $line .= ' called at ['.$entry['file'].':'.$entry['line'].']';
68
69 }
70 $details[] = $line;
71 $details[] = "\n";
72 }
73
74 $details[] = hsprintf('</div>');
75 }
76
77 $table = new AphrontTableView($rows);
78 $table->setClassName('error-log');
79 $table->setHeaders(array(pht('Error')));
80 $table->setNoDataString(pht('No errors.'));
81
82 return phutil_tag(
83 'div',
84 array(),
85 array(
86 phutil_tag('div', array(), $table->render()),
87 phutil_tag('pre', array('class' => 'PhabricatorMonospaced'), $details),
88 ));
89 }
90
91}