2011-02-02 13:48:52 -08:00
|
|
|
<?php
|
|
|
|
|
2011-09-14 08:02:31 -07:00
|
|
|
/**
|
|
|
|
* @group console
|
|
|
|
*/
|
2012-03-13 11:18:11 -07:00
|
|
|
final class DarkConsoleErrorLogPlugin extends DarkConsolePlugin {
|
2011-02-02 13:48:52 -08:00
|
|
|
|
|
|
|
public function getName() {
|
|
|
|
$count = count($this->getData());
|
|
|
|
if ($count) {
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-28 18:45:32 -08:00
|
|
|
return pht('Error Log (%d)', $count);
|
2011-02-02 13:48:52 -08:00
|
|
|
}
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-28 18:45:32 -08:00
|
|
|
return pht('Error Log');
|
|
|
|
}
|
2011-02-02 13:48:52 -08:00
|
|
|
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-28 18:45:32 -08:00
|
|
|
public function getOrder() {
|
|
|
|
return 0;
|
2011-02-02 13:48:52 -08:00
|
|
|
}
|
|
|
|
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-28 18:45:32 -08:00
|
|
|
public function getColor() {
|
|
|
|
if (count($this->getData())) {
|
|
|
|
return '#ff0000';
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2011-02-02 13:48:52 -08:00
|
|
|
|
|
|
|
public function getDescription() {
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-28 18:45:32 -08:00
|
|
|
return pht('Shows errors and warnings.');
|
2011-02-02 13:48:52 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public function generateData() {
|
2011-02-02 22:38:42 -08:00
|
|
|
return DarkConsoleErrorLogPluginAPI::getErrors();
|
|
|
|
}
|
|
|
|
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-28 18:45:32 -08:00
|
|
|
public function renderPanel() {
|
2011-02-02 22:38:42 -08:00
|
|
|
$data = $this->getData();
|
2011-02-02 13:48:52 -08:00
|
|
|
|
2011-02-02 22:38:42 -08:00
|
|
|
$rows = array();
|
2013-02-13 14:50:15 -08:00
|
|
|
$details = array();
|
2011-04-05 12:24:21 -07:00
|
|
|
|
|
|
|
foreach ($data as $index => $row) {
|
|
|
|
$file = $row['file'];
|
|
|
|
$line = $row['line'];
|
|
|
|
|
2013-01-17 18:43:35 -08:00
|
|
|
$tag = phutil_tag(
|
2011-04-05 12:24:21 -07:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'onclick' => jsprintf('show_details(%d)', $index),
|
|
|
|
),
|
2013-01-17 18:43:35 -08:00
|
|
|
$row['str'].' at ['.basename($file).':'.$line.']');
|
2011-04-05 12:24:21 -07:00
|
|
|
$rows[] = array($tag);
|
|
|
|
|
2013-02-13 14:50:15 -08:00
|
|
|
$details[] = hsprintf(
|
|
|
|
'<div class="dark-console-panel-error-details" id="row-details-%s">'.
|
|
|
|
"%s\nStack trace:\n",
|
|
|
|
$index,
|
|
|
|
$row['details']);
|
2011-04-05 12:24:21 -07:00
|
|
|
|
|
|
|
foreach ($row['trace'] as $key => $entry) {
|
|
|
|
$line = '';
|
|
|
|
if (isset($entry['class'])) {
|
|
|
|
$line .= $entry['class'].'::';
|
|
|
|
}
|
|
|
|
$line .= idx($entry, 'function', '');
|
2012-04-18 12:50:06 -07:00
|
|
|
$href = null;
|
2011-04-05 12:24:21 -07:00
|
|
|
if (isset($entry['file'])) {
|
|
|
|
$line .= ' called at ['.$entry['file'].':'.$entry['line'].']';
|
2012-04-18 12:50:06 -07:00
|
|
|
try {
|
|
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
$href = $user->loadEditorLink($entry['file'], $entry['line'], '');
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
// The database can be inaccessible.
|
|
|
|
}
|
2011-04-05 12:24:21 -07:00
|
|
|
}
|
|
|
|
|
2013-02-13 14:50:15 -08:00
|
|
|
$details[] = phutil_tag(
|
2011-04-05 12:24:21 -07:00
|
|
|
'a',
|
|
|
|
array(
|
2012-04-18 12:50:06 -07:00
|
|
|
'href' => $href,
|
2011-04-05 12:24:21 -07:00
|
|
|
),
|
2013-01-17 18:43:35 -08:00
|
|
|
$line);
|
2013-02-13 14:50:15 -08:00
|
|
|
$details[] = "\n";
|
2011-02-02 13:48:52 -08:00
|
|
|
}
|
2011-02-02 22:38:42 -08:00
|
|
|
|
2013-02-13 14:50:15 -08:00
|
|
|
$details[] = hsprintf('</div>');
|
2011-02-02 13:48:52 -08:00
|
|
|
}
|
|
|
|
|
2011-02-02 22:38:42 -08:00
|
|
|
$table = new AphrontTableView($rows);
|
2011-04-05 12:24:21 -07:00
|
|
|
$table->setClassName('error-log');
|
|
|
|
$table->setHeaders(array('Error'));
|
2011-02-02 22:38:42 -08:00
|
|
|
$table->setNoDataString('No errors.');
|
|
|
|
|
2013-02-13 14:50:15 -08:00
|
|
|
return hsprintf(
|
|
|
|
'<div>'.
|
|
|
|
'<div>%s</div>'.
|
|
|
|
'<pre class="PhabricatorMonospaced">%s</pre>'.
|
|
|
|
'</div>',
|
|
|
|
$table->render(),
|
|
|
|
phutil_implode_html('', $details));
|
2011-02-02 22:38:42 -08:00
|
|
|
}
|
|
|
|
}
|
2011-02-02 13:48:52 -08:00
|
|
|
|
|
|
|
/*
|
|
|
|
$data = $this->getData();
|
|
|
|
if (!$data) {
|
|
|
|
return
|
|
|
|
<x:frag>
|
|
|
|
<div class="mu">No errors.</div>
|
|
|
|
</x:frag>;
|
|
|
|
}
|
|
|
|
|
|
|
|
$markup = <table class="LConsoleErrors" />;
|
|
|
|
$alt = false;
|
|
|
|
foreach ($data as $error) {
|
|
|
|
$row = <tr class={$alt ? 'alt' : null} />;
|
|
|
|
|
|
|
|
$text = $error['error'];
|
|
|
|
$text = preg_replace('/\(in .* on line \d+\)$/', '', trim($text));
|
|
|
|
|
|
|
|
$trace = $error['trace'];
|
|
|
|
$trace = explode("\n", $trace);
|
|
|
|
if (!$trace) {
|
|
|
|
$trace = array('unknown@0@unknown');
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($trace as $idx => $traceline) {
|
|
|
|
list($file, $line, $where) = array_merge(
|
|
|
|
explode('@', $traceline),
|
|
|
|
array('?', '?', '?'));
|
|
|
|
if ($where == 'DarkConsole->addError' ||
|
|
|
|
$where == 'debug_rlog') {
|
|
|
|
unset($trace[$idx]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$row->appendChild(<th rowspan={count($trace)}>{$text}</th>);
|
|
|
|
|
|
|
|
foreach ($trace as $traceline) {
|
|
|
|
list($file, $line, $where) = array_merge(
|
|
|
|
explode('@', $traceline),
|
|
|
|
array('?', '?', '?'));
|
|
|
|
$row->appendChild(<td>{$file}:{$line}</td>);
|
|
|
|
$row->appendChild(<td>{$where}()</td>);
|
|
|
|
$markup->appendChild($row);
|
|
|
|
$row = <tr class={$alt ? 'alt' : null} />;
|
|
|
|
}
|
|
|
|
|
|
|
|
$alt = !$alt;
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
<x:frag>
|
|
|
|
<h1>Errors</h1>
|
|
|
|
<div class="LConsoleErrors">{$markup}</div>
|
|
|
|
</x:frag>;
|
|
|
|
*/
|