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:
meadsteve 2013-10-27 14:21:08 +00:00
parent fc2434b65d
commit e44c7b90d6
2 changed files with 36 additions and 0 deletions

View file

@ -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);
}

View 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;
}
}