mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +01:00
Add PhabricatorWorker->log()
Summary: Ref T2852. Add a `log()` method to `PhabricatorWorker` to make debugging easier. I renamed the similar Drydock-specific method. Test Plan: Used logging in a future revision: ... <<< [36] <http> 211,704 us Updating main task. >>> [37] <http> https://app.asana.com/api/1.0/tasks/6153776820388 ... Reviewers: btrahan, chad Reviewed By: chad CC: aran Maniphest Tasks: T2852 Differential Revision: https://secure.phabricator.com/D6296
This commit is contained in:
parent
5ecb77427a
commit
d4ca508d2b
2 changed files with 15 additions and 8 deletions
|
@ -23,7 +23,7 @@ final class DrydockAllocatorWorker extends PhabricatorWorker {
|
|||
return $this->lease;
|
||||
}
|
||||
|
||||
private function log($message) {
|
||||
private function logToDrydock($message) {
|
||||
DrydockBlueprint::writeLog(
|
||||
null,
|
||||
$this->loadLease(),
|
||||
|
@ -32,7 +32,7 @@ final class DrydockAllocatorWorker extends PhabricatorWorker {
|
|||
|
||||
protected function doWork() {
|
||||
$lease = $this->loadLease();
|
||||
$this->log('Allocating Lease');
|
||||
$this->logToDrydock('Allocating Lease');
|
||||
|
||||
try {
|
||||
$this->allocateLease($lease);
|
||||
|
@ -60,7 +60,7 @@ final class DrydockAllocatorWorker extends PhabricatorWorker {
|
|||
$lease->getResourceType(),
|
||||
DrydockResourceStatus::STATUS_OPEN);
|
||||
|
||||
$this->log(
|
||||
$this->logToDrydock(
|
||||
pht('Found %d Open Resource(s)', count($pool)));
|
||||
|
||||
$candidates = array();
|
||||
|
@ -77,7 +77,7 @@ final class DrydockAllocatorWorker extends PhabricatorWorker {
|
|||
}
|
||||
}
|
||||
|
||||
$this->log(pht('%d Open Resource(s) Remain', count($candidates)));
|
||||
$this->logToDrydock(pht('%d Open Resource(s) Remain', count($candidates)));
|
||||
|
||||
$resource = null;
|
||||
if ($candidates) {
|
||||
|
@ -94,7 +94,7 @@ final class DrydockAllocatorWorker extends PhabricatorWorker {
|
|||
if (!$resource) {
|
||||
$blueprints = DrydockBlueprint::getAllBlueprintsForResource($type);
|
||||
|
||||
$this->log(
|
||||
$this->logToDrydock(
|
||||
pht('Found %d Blueprints', count($blueprints)));
|
||||
|
||||
foreach ($blueprints as $key => $candidate_blueprint) {
|
||||
|
@ -104,7 +104,7 @@ final class DrydockAllocatorWorker extends PhabricatorWorker {
|
|||
}
|
||||
}
|
||||
|
||||
$this->log(
|
||||
$this->logToDrydock(
|
||||
pht('%d Blueprints Enabled', count($blueprints)));
|
||||
|
||||
foreach ($blueprints as $key => $candidate_blueprint) {
|
||||
|
@ -114,14 +114,14 @@ final class DrydockAllocatorWorker extends PhabricatorWorker {
|
|||
}
|
||||
}
|
||||
|
||||
$this->log(
|
||||
$this->logToDrydock(
|
||||
pht('%d Blueprints Can Allocate', count($blueprints)));
|
||||
|
||||
if (!$blueprints) {
|
||||
$lease->setStatus(DrydockLeaseStatus::STATUS_BROKEN);
|
||||
$lease->save();
|
||||
|
||||
$this->log(
|
||||
$this->logToDrydock(
|
||||
"There are no resources of type '{$type}' available, and no ".
|
||||
"blueprints which can allocate new ones.");
|
||||
|
||||
|
|
|
@ -169,4 +169,11 @@ abstract class PhabricatorWorker {
|
|||
self::$runAllTasksInProcess = $all;
|
||||
}
|
||||
|
||||
protected function log($pattern /* $args */) {
|
||||
$console = PhutilConsole::getConsole();
|
||||
$argv = func_get_args();
|
||||
call_user_func_array(array($console, 'writeLog'), $argv);
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue