mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10:55 +01:00
Daemons - move combined log to console
Summary: Fixes T5405. Test Plan: ran a few commands (log, log --id X --id Y, log --id BADX, log --id BADX --id BADY) and verified good output Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T5405 Differential Revision: https://secure.phabricator.com/D10371
This commit is contained in:
parent
2fdd7f0f3d
commit
06882a99cf
6 changed files with 41 additions and 74 deletions
|
@ -1375,7 +1375,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorCustomFieldStorage' => 'infrastructure/customfield/storage/PhabricatorCustomFieldStorage.php',
|
||||
'PhabricatorCustomFieldStringIndexStorage' => 'infrastructure/customfield/storage/PhabricatorCustomFieldStringIndexStorage.php',
|
||||
'PhabricatorDaemon' => 'infrastructure/daemon/PhabricatorDaemon.php',
|
||||
'PhabricatorDaemonCombinedLogController' => 'applications/daemon/controller/PhabricatorDaemonCombinedLogController.php',
|
||||
'PhabricatorDaemonConsoleController' => 'applications/daemon/controller/PhabricatorDaemonConsoleController.php',
|
||||
'PhabricatorDaemonController' => 'applications/daemon/controller/PhabricatorDaemonController.php',
|
||||
'PhabricatorDaemonDAO' => 'applications/daemon/storage/PhabricatorDaemonDAO.php',
|
||||
|
@ -4214,7 +4213,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorCustomFieldStorage' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorCustomFieldStringIndexStorage' => 'PhabricatorCustomFieldIndexStorage',
|
||||
'PhabricatorDaemon' => 'PhutilDaemon',
|
||||
'PhabricatorDaemonCombinedLogController' => 'PhabricatorDaemonController',
|
||||
'PhabricatorDaemonConsoleController' => 'PhabricatorDaemonController',
|
||||
'PhabricatorDaemonController' => 'PhabricatorController',
|
||||
'PhabricatorDaemonDAO' => 'PhabricatorLiskDAO',
|
||||
|
|
|
@ -45,7 +45,6 @@ final class PhabricatorDaemonsApplication extends PhabricatorApplication {
|
|||
=> 'PhabricatorWorkerTaskUpdateController',
|
||||
'log/' => array(
|
||||
'' => 'PhabricatorDaemonLogListController',
|
||||
'combined/' => 'PhabricatorDaemonCombinedLogController',
|
||||
'(?P<id>[1-9]\d*)/' => 'PhabricatorDaemonLogViewController',
|
||||
),
|
||||
'event/(?P<id>[1-9]\d*)/' => 'PhabricatorDaemonLogEventViewController',
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorDaemonCombinedLogController
|
||||
extends PhabricatorDaemonController {
|
||||
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
|
||||
$pager = new AphrontPagerView();
|
||||
$pager->setOffset($request->getInt('page'));
|
||||
$pager->setPageSize(1000);
|
||||
|
||||
$events = id(new PhabricatorDaemonLogEvent())->loadAllWhere(
|
||||
'1 = 1 ORDER BY id DESC LIMIT %d, %d',
|
||||
$pager->getOffset(),
|
||||
$pager->getPageSize() + 1);
|
||||
|
||||
$events = $pager->sliceResults($events);
|
||||
$pager->setURI($request->getRequestURI(), 'page');
|
||||
|
||||
$event_view = new PhabricatorDaemonLogEventsView();
|
||||
$event_view->setEvents($events);
|
||||
$event_view->setUser($request->getUser());
|
||||
$event_view->setCombinedLog(true);
|
||||
|
||||
$log_panel = new AphrontPanelView();
|
||||
$log_panel->setHeader('Combined Daemon Logs');
|
||||
$log_panel->appendChild($event_view);
|
||||
$log_panel->appendChild($pager);
|
||||
$log_panel->setNoBackground();
|
||||
|
||||
$nav = $this->buildSideNavView();
|
||||
$nav->selectFilter('log/combined');
|
||||
$nav->appendChild($log_panel);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
$nav,
|
||||
array(
|
||||
'title' => pht('Combined Daemon Log'),
|
||||
'device' => false,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
|
@ -9,7 +9,6 @@ abstract class PhabricatorDaemonController extends PhabricatorController {
|
|||
$nav->addLabel(pht('Daemons'));
|
||||
$nav->addFilter('/', pht('Console'));
|
||||
$nav->addFilter('log', pht('All Daemons'));
|
||||
$nav->addFilter('log/combined', pht('Combined Log'));
|
||||
|
||||
return $nav;
|
||||
}
|
||||
|
|
|
@ -6,52 +6,62 @@ final class PhabricatorDaemonManagementLogWorkflow
|
|||
public function didConstruct() {
|
||||
$this
|
||||
->setName('log')
|
||||
->setExamples('**log** __id__')
|
||||
->setExamples('**log** [__options__]')
|
||||
->setSynopsis(
|
||||
pht(
|
||||
'Print the log for a daemon, identified by ID. You can get the '.
|
||||
'ID for a daemon from the Daemon Console in the web interface.'))
|
||||
'Print the logs for all daemons, or some daemon(s) identified by '.
|
||||
'ID. You can get the ID for a daemon from the Daemon Console in '.
|
||||
'the web interface.'))
|
||||
->setArguments(
|
||||
array(
|
||||
array(
|
||||
'name' => 'daemon',
|
||||
'wildcard' => true,
|
||||
'name' => 'id',
|
||||
'param' => 'id',
|
||||
'help' => 'Show logs for daemon(s) with given ID(s).',
|
||||
'repeat' => true,
|
||||
),
|
||||
array(
|
||||
'name' => 'limit',
|
||||
'param' => 'N',
|
||||
'default' => 100,
|
||||
'help' => 'Show a specific number of log messages '.
|
||||
'(default 100).',
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
public function execute(PhutilArgumentParser $args) {
|
||||
$id = $args->getArg('daemon');
|
||||
if (!$id) {
|
||||
throw new PhutilArgumentUsageException(
|
||||
pht('You must specify the daemon ID to show logs for.'));
|
||||
} else if (count($id) > 1) {
|
||||
throw new PhutilArgumentUsageException(
|
||||
pht('Specify exactly one daemon ID to show logs for.'));
|
||||
}
|
||||
$id = head($id);
|
||||
|
||||
$daemon = id(new PhabricatorDaemonLogQuery())
|
||||
$query = id(new PhabricatorDaemonLogQuery())
|
||||
->setViewer($this->getViewer())
|
||||
->withIDs(array($id))
|
||||
->setAllowStatusWrites(true)
|
||||
->executeOne();
|
||||
->setAllowStatusWrites(true);
|
||||
$ids = $args->getArg('id');
|
||||
if ($ids) {
|
||||
$query->withIDs($ids);
|
||||
}
|
||||
$daemons = $query->execute();
|
||||
|
||||
if (!$daemon) {
|
||||
if (!$daemons) {
|
||||
if ($ids) {
|
||||
throw new PhutilArgumentUsageException(
|
||||
pht('No such daemon with id "%s"!', $id));
|
||||
pht('No daemon(s) with id(s) "%s" exist!', implode(', ', $ids)));
|
||||
} else {
|
||||
throw new PhutilArgumentUsageException(
|
||||
pht('No daemons are running.'));
|
||||
}
|
||||
}
|
||||
|
||||
$console = PhutilConsole::getConsole();
|
||||
$logs = id(new PhabricatorDaemonLogEvent())->loadAllWhere(
|
||||
'logID = %d ORDER BY id ASC',
|
||||
$daemon->getID());
|
||||
'logID IN (%Ld) ORDER BY id ASC',
|
||||
mpull($daemons, 'getID'));
|
||||
|
||||
$lines = array();
|
||||
foreach ($logs as $log) {
|
||||
$text_lines = phutil_split_lines($log->getMessage(), $retain = false);
|
||||
foreach ($text_lines as $line) {
|
||||
$lines[] = array(
|
||||
'id' => $log->getLogID(),
|
||||
'type' => $log->getLogType(),
|
||||
'date' => $log->getEpoch(),
|
||||
'data' => $line,
|
||||
|
@ -60,6 +70,7 @@ final class PhabricatorDaemonManagementLogWorkflow
|
|||
}
|
||||
|
||||
foreach ($lines as $line) {
|
||||
$id = $line['id'];
|
||||
$type = $line['type'];
|
||||
$data = $line['data'];
|
||||
$date = date('r', $line['date']);
|
||||
|
@ -67,9 +78,10 @@ final class PhabricatorDaemonManagementLogWorkflow
|
|||
$console->writeOut(
|
||||
"%s\n",
|
||||
sprintf(
|
||||
'[%s] %s %s',
|
||||
$date,
|
||||
'Daemon %d %s [%s] %s',
|
||||
$id,
|
||||
$type,
|
||||
$date,
|
||||
$data));
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,10 @@ abstract class PhabricatorBaseEnglishTranslation
|
|||
|
||||
public function getTranslations() {
|
||||
return array(
|
||||
'No daemon(s) with id(s) "%s" exist!' => array(
|
||||
'No daemon with id %s exists!',
|
||||
'No daemons with ids %s exist!',
|
||||
),
|
||||
'These %d configuration value(s) are related:' => array(
|
||||
'This configuration value is related:',
|
||||
'These configuration values are related:',
|
||||
|
|
Loading…
Reference in a new issue