diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1375,7 +1375,6 @@ '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 @@ 'PhabricatorCustomFieldStorage' => 'PhabricatorLiskDAO', 'PhabricatorCustomFieldStringIndexStorage' => 'PhabricatorCustomFieldIndexStorage', 'PhabricatorDaemon' => 'PhutilDaemon', - 'PhabricatorDaemonCombinedLogController' => 'PhabricatorDaemonController', 'PhabricatorDaemonConsoleController' => 'PhabricatorDaemonController', 'PhabricatorDaemonController' => 'PhabricatorController', 'PhabricatorDaemonDAO' => 'PhabricatorLiskDAO', diff --git a/src/applications/daemon/application/PhabricatorDaemonsApplication.php b/src/applications/daemon/application/PhabricatorDaemonsApplication.php --- a/src/applications/daemon/application/PhabricatorDaemonsApplication.php +++ b/src/applications/daemon/application/PhabricatorDaemonsApplication.php @@ -45,7 +45,6 @@ => 'PhabricatorWorkerTaskUpdateController', 'log/' => array( '' => 'PhabricatorDaemonLogListController', - 'combined/' => 'PhabricatorDaemonCombinedLogController', '(?P[1-9]\d*)/' => 'PhabricatorDaemonLogViewController', ), 'event/(?P[1-9]\d*)/' => 'PhabricatorDaemonLogEventViewController', diff --git a/src/applications/daemon/controller/PhabricatorDaemonCombinedLogController.php b/src/applications/daemon/controller/PhabricatorDaemonCombinedLogController.php deleted file mode 100644 --- a/src/applications/daemon/controller/PhabricatorDaemonCombinedLogController.php +++ /dev/null @@ -1,45 +0,0 @@ -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, - )); - } - -} diff --git a/src/applications/daemon/controller/PhabricatorDaemonController.php b/src/applications/daemon/controller/PhabricatorDaemonController.php --- a/src/applications/daemon/controller/PhabricatorDaemonController.php +++ b/src/applications/daemon/controller/PhabricatorDaemonController.php @@ -9,7 +9,6 @@ $nav->addLabel(pht('Daemons')); $nav->addFilter('/', pht('Console')); $nav->addFilter('log', pht('All Daemons')); - $nav->addFilter('log/combined', pht('Combined Log')); return $nav; } diff --git a/src/applications/daemon/management/PhabricatorDaemonManagementLogWorkflow.php b/src/applications/daemon/management/PhabricatorDaemonManagementLogWorkflow.php --- a/src/applications/daemon/management/PhabricatorDaemonManagementLogWorkflow.php +++ b/src/applications/daemon/management/PhabricatorDaemonManagementLogWorkflow.php @@ -6,52 +6,62 @@ 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) { - throw new PhutilArgumentUsageException( - pht('No such daemon with id "%s"!', $id)); + if (!$daemons) { + if ($ids) { + throw new PhutilArgumentUsageException( + 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 @@ } foreach ($lines as $line) { + $id = $line['id']; $type = $line['type']; $data = $line['data']; $date = date('r', $line['date']); @@ -67,9 +78,10 @@ $console->writeOut( "%s\n", sprintf( - '[%s] %s %s', - $date, + 'Daemon %d %s [%s] %s', + $id, $type, + $date, $data)); } diff --git a/src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php b/src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php --- a/src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php +++ b/src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php @@ -9,6 +9,10 @@ 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:',