2011-02-02 13:48:52 -08:00
|
|
|
<?php
|
|
|
|
|
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'];
|
|
|
|
|
2018-03-13 16:26:01 -07:00
|
|
|
$tag = javelin_tag(
|
2011-04-05 12:24:21 -07:00
|
|
|
'a',
|
|
|
|
array(
|
2018-03-13 16:26:01 -07:00
|
|
|
'sigil' => 'darkconsole-expand',
|
|
|
|
'meta' => array(
|
|
|
|
'expandID' => 'row-details-'.$index,
|
|
|
|
),
|
2011-04-05 12:24:21 -07:00
|
|
|
),
|
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();
|
2016-01-02 11:56:19 -08:00
|
|
|
$href = $user->loadEditorLink($entry['file'], $entry['line'], null);
|
2012-04-18 12:50:06 -07:00
|
|
|
} 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');
|
2015-05-22 17:27:56 +10:00
|
|
|
$table->setHeaders(array(pht('Error')));
|
|
|
|
$table->setNoDataString(pht('No errors.'));
|
2011-02-02 22:38:42 -08:00
|
|
|
|
2013-11-08 20:44:24 -08:00
|
|
|
return phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(),
|
|
|
|
array(
|
|
|
|
phutil_tag('div', array(), $table->render()),
|
|
|
|
phutil_tag('pre', array('class' => 'PhabricatorMonospaced'), $details),
|
|
|
|
));
|
2011-02-02 22:38:42 -08:00
|
|
|
}
|
2014-07-10 08:12:48 +10:00
|
|
|
|
2011-02-02 22:38:42 -08:00
|
|
|
}
|