mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-26 07:20:57 +01:00
Provide a convenient way to log arbitrary text in Drydock without needing structured log classes
Summary: Depends on D19673. Ref T13197. See PHI873. Test Plan: Added some code like this: ``` $operation->logText('Nice convenient text logging.'); ``` ...then got: {F5887712} Reviewers: amckinley Reviewed By: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13197 Differential Revision: https://secure.phabricator.com/D19674
This commit is contained in:
parent
a7e060f062
commit
0167f357b7
3 changed files with 37 additions and 0 deletions
|
@ -1206,6 +1206,7 @@ phutil_register_library_map(array(
|
|||
'DrydockSlotLockException' => 'applications/drydock/exception/DrydockSlotLockException.php',
|
||||
'DrydockSlotLockFailureLogType' => 'applications/drydock/logtype/DrydockSlotLockFailureLogType.php',
|
||||
'DrydockTestRepositoryOperation' => 'applications/drydock/operation/DrydockTestRepositoryOperation.php',
|
||||
'DrydockTextLogType' => 'applications/drydock/logtype/DrydockTextLogType.php',
|
||||
'DrydockWebrootInterface' => 'applications/drydock/interface/webroot/DrydockWebrootInterface.php',
|
||||
'DrydockWorker' => 'applications/drydock/worker/DrydockWorker.php',
|
||||
'DrydockWorkingCopyBlueprintImplementation' => 'applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php',
|
||||
|
@ -6620,6 +6621,7 @@ phutil_register_library_map(array(
|
|||
'DrydockSlotLockException' => 'Exception',
|
||||
'DrydockSlotLockFailureLogType' => 'DrydockLogType',
|
||||
'DrydockTestRepositoryOperation' => 'DrydockRepositoryOperationType',
|
||||
'DrydockTextLogType' => 'DrydockLogType',
|
||||
'DrydockWebrootInterface' => 'DrydockInterface',
|
||||
'DrydockWorker' => 'PhabricatorWorker',
|
||||
'DrydockWorkingCopyBlueprintImplementation' => 'DrydockBlueprintImplementation',
|
||||
|
|
27
src/applications/drydock/logtype/DrydockTextLogType.php
Normal file
27
src/applications/drydock/logtype/DrydockTextLogType.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Simple convenience log type for logging arbitrary text.
|
||||
*
|
||||
* Drydock logs can be given formal types, which allows them to be translated
|
||||
* and filtered. If you don't particularly care about fancy logging features,
|
||||
* you can use this log type to just dump some text into the log. Maybe you
|
||||
* could upgrade to more formal logging later.
|
||||
*/
|
||||
final class DrydockTextLogType extends DrydockLogType {
|
||||
|
||||
const LOGCONST = 'core.text';
|
||||
|
||||
public function getLogTypeName() {
|
||||
return pht('Text');
|
||||
}
|
||||
|
||||
public function getLogTypeIcon(array $data) {
|
||||
return 'fa-file-text-o grey';
|
||||
}
|
||||
|
||||
public function renderLog(array $data) {
|
||||
return idx($data, 'text');
|
||||
}
|
||||
|
||||
}
|
|
@ -203,6 +203,14 @@ final class DrydockRepositoryOperation extends DrydockDAO
|
|||
return $this->getProperty('exec.workingcopy.error');
|
||||
}
|
||||
|
||||
public function logText($text) {
|
||||
return $this->logEvent(
|
||||
DrydockTextLogType::LOGCONST,
|
||||
array(
|
||||
'text' => $text,
|
||||
));
|
||||
}
|
||||
|
||||
public function logEvent($type, array $data = array()) {
|
||||
$log = id(new DrydockLog())
|
||||
->setEpoch(PhabricatorTime::getNow())
|
||||
|
|
Loading…
Reference in a new issue