All build logs calls now pass the build through as part of the context so this gets recorded in the log message.
This commit is contained in:
parent
fc2434b65d
commit
e44c7b90d6
|
@ -246,6 +246,11 @@ class Builder implements LoggerAwareInterface
|
|||
if (!is_array($message)) {
|
||||
$message = array($message);
|
||||
}
|
||||
|
||||
// The build is added to the context so the logger can use
|
||||
// details from it if required.
|
||||
$context['build'] = $this;
|
||||
|
||||
foreach ($message as $item) {
|
||||
$this->logger->log($level, $item, $context);
|
||||
}
|
||||
|
|
31
PHPCI/Helper/LoggedBuildContextTidier.php
Normal file
31
PHPCI/Helper/LoggedBuildContextTidier.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace PHPCI\Helper;
|
||||
|
||||
|
||||
class LoggedBuildContextTidier{
|
||||
|
||||
function __invoke()
|
||||
{
|
||||
return $this->tidyLoggedBuildContext(func_get_arg(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the build object from the logged record and adds the ID as
|
||||
* this is more useful to display.
|
||||
*
|
||||
* @param array $logRecord
|
||||
* @return array
|
||||
*/
|
||||
protected function tidyLoggedBuildContext(array $logRecord)
|
||||
{
|
||||
if (isset($logRecord['context']['build'])) {
|
||||
$build = $logRecord['context']['build'];
|
||||
if ($build instanceof Build) {
|
||||
$logRecord['context']['buildID'] = $build->getId();
|
||||
unset($logRecord['context']['build']);
|
||||
}
|
||||
}
|
||||
return $logRecord;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue