1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 14:00:56 +01:00

Tweak --limit for bin/phd log

Summary:
Ref T5405.

  - `--limit` wasn't actually used anywhere.
  - Make it mean "the N newest lines".

Test Plan: Ran `bin/phd log`, `bin/phd log --limit 3`.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5405

Differential Revision: https://secure.phabricator.com/D10385
This commit is contained in:
epriestley 2014-08-29 10:02:19 -07:00
parent f015cb50fe
commit 340b40172f

View file

@ -52,9 +52,14 @@ final class PhabricatorDaemonManagementLogWorkflow
}
$console = PhutilConsole::getConsole();
$limit = $args->getArg('limit');
$logs = id(new PhabricatorDaemonLogEvent())->loadAllWhere(
'logID IN (%Ld) ORDER BY id ASC',
mpull($daemons, 'getID'));
'logID IN (%Ld) ORDER BY id DESC LIMIT %d',
mpull($daemons, 'getID'),
$limit);
$logs = array_reverse($logs);
$lines = array();
foreach ($logs as $log) {
@ -69,6 +74,11 @@ final class PhabricatorDaemonManagementLogWorkflow
}
}
// Each log message may be several lines. Limit the number of lines we
// output so that `--limit 123` means "show 123 lines", which is the most
// easily understandable behavior.
$lines = array_slice($lines, -$limit);
foreach ($lines as $line) {
$id = $line['id'];
$type = $line['type'];