mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 02:32:42 +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;
|
return $this->lease;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function log($message) {
|
private function logToDrydock($message) {
|
||||||
DrydockBlueprint::writeLog(
|
DrydockBlueprint::writeLog(
|
||||||
null,
|
null,
|
||||||
$this->loadLease(),
|
$this->loadLease(),
|
||||||
|
@ -32,7 +32,7 @@ final class DrydockAllocatorWorker extends PhabricatorWorker {
|
||||||
|
|
||||||
protected function doWork() {
|
protected function doWork() {
|
||||||
$lease = $this->loadLease();
|
$lease = $this->loadLease();
|
||||||
$this->log('Allocating Lease');
|
$this->logToDrydock('Allocating Lease');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->allocateLease($lease);
|
$this->allocateLease($lease);
|
||||||
|
@ -60,7 +60,7 @@ final class DrydockAllocatorWorker extends PhabricatorWorker {
|
||||||
$lease->getResourceType(),
|
$lease->getResourceType(),
|
||||||
DrydockResourceStatus::STATUS_OPEN);
|
DrydockResourceStatus::STATUS_OPEN);
|
||||||
|
|
||||||
$this->log(
|
$this->logToDrydock(
|
||||||
pht('Found %d Open Resource(s)', count($pool)));
|
pht('Found %d Open Resource(s)', count($pool)));
|
||||||
|
|
||||||
$candidates = array();
|
$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;
|
$resource = null;
|
||||||
if ($candidates) {
|
if ($candidates) {
|
||||||
|
@ -94,7 +94,7 @@ final class DrydockAllocatorWorker extends PhabricatorWorker {
|
||||||
if (!$resource) {
|
if (!$resource) {
|
||||||
$blueprints = DrydockBlueprint::getAllBlueprintsForResource($type);
|
$blueprints = DrydockBlueprint::getAllBlueprintsForResource($type);
|
||||||
|
|
||||||
$this->log(
|
$this->logToDrydock(
|
||||||
pht('Found %d Blueprints', count($blueprints)));
|
pht('Found %d Blueprints', count($blueprints)));
|
||||||
|
|
||||||
foreach ($blueprints as $key => $candidate_blueprint) {
|
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)));
|
pht('%d Blueprints Enabled', count($blueprints)));
|
||||||
|
|
||||||
foreach ($blueprints as $key => $candidate_blueprint) {
|
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)));
|
pht('%d Blueprints Can Allocate', count($blueprints)));
|
||||||
|
|
||||||
if (!$blueprints) {
|
if (!$blueprints) {
|
||||||
$lease->setStatus(DrydockLeaseStatus::STATUS_BROKEN);
|
$lease->setStatus(DrydockLeaseStatus::STATUS_BROKEN);
|
||||||
$lease->save();
|
$lease->save();
|
||||||
|
|
||||||
$this->log(
|
$this->logToDrydock(
|
||||||
"There are no resources of type '{$type}' available, and no ".
|
"There are no resources of type '{$type}' available, and no ".
|
||||||
"blueprints which can allocate new ones.");
|
"blueprints which can allocate new ones.");
|
||||||
|
|
||||||
|
|
|
@ -169,4 +169,11 @@ abstract class PhabricatorWorker {
|
||||||
self::$runAllTasksInProcess = $all;
|
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