Path: blob/master/src/applications/console/plugin/DarkConsoleErrorLogPlugin.php
13402 views
<?php12final class DarkConsoleErrorLogPlugin extends DarkConsolePlugin {34public function getName() {5$count = count($this->getData());6if ($count) {7return pht('Error Log (%d)', $count);8}9return pht('Error Log');10}1112public function getOrder() {13return 0;14}1516public function getColor() {17if (count($this->getData())) {18return '#ff0000';19}20return null;21}2223public function getDescription() {24return pht('Shows errors and warnings.');25}2627public function generateData() {28return DarkConsoleErrorLogPluginAPI::getErrors();29}3031public function renderPanel() {32$data = $this->getData();3334$rows = array();35$details = array();3637foreach ($data as $index => $row) {38$file = $row['file'];39$line = $row['line'];4041$tag = javelin_tag(42'a',43array(44'sigil' => 'darkconsole-expand',45'meta' => array(46'expandID' => 'row-details-'.$index,47),48),49$row['str'].' at ['.basename($file).':'.$line.']');50$rows[] = array($tag);5152$details[] = hsprintf(53'<div class="dark-console-panel-error-details" id="row-details-%s">'.54"%s\nStack trace:\n",55$index,56$row['details']);5758foreach ($row['trace'] as $key => $entry) {59$line = '';60if (isset($entry['class'])) {61$line .= $entry['class'].'::';62}63$line .= idx($entry, 'function', '');64$href = null;65if (isset($entry['file'])) {66$line .= ' called at ['.$entry['file'].':'.$entry['line'].']';6768}69$details[] = $line;70$details[] = "\n";71}7273$details[] = hsprintf('</div>');74}7576$table = new AphrontTableView($rows);77$table->setClassName('error-log');78$table->setHeaders(array(pht('Error')));79$table->setNoDataString(pht('No errors.'));8081return phutil_tag(82'div',83array(),84array(85phutil_tag('div', array(), $table->render()),86phutil_tag('pre', array('class' => 'PhabricatorMonospaced'), $details),87));88}8990}919293