php-censor/src/PHPCensor/Logging/LoggedBuildContextTidier.php

39 lines
902 B
PHP
Raw Normal View History

<?php
2016-07-19 20:28:11 +02:00
namespace PHPCensor\Logging;
2016-07-19 20:28:11 +02:00
use PHPCensor\Model\Build;
/**
* Class LoggedBuildContextTidier cleans up build log entries.
*/
class LoggedBuildContextTidier
{
/**
* @return array
*/
2014-02-27 15:23:51 +01:00
public 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;
}
2014-02-27 15:23:51 +01:00
}