for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Oqq\Minc\Log\Processor;
use Oqq\Minc\Log\Record;
/**
* @author Eric Braun <[email protected]>
*/
class ContextReplacementProcessor implements ProcessorInterface
{
* @inheritdoc
public function process(Record $record)
$record->setMessage(strtr($record->getMessage(), $this->getReplacements($record)));
}
* @param Record $record
*
* @return array
protected function getReplacements(Record $record)
$replacements = [];
foreach ($record->getContext() as $key => $val) {
if (null === $val || is_scalar($val) || method_exists($val, '__toString')) {
$replacements['{'.$key.'}'] = $val;
} elseif (is_object($val)) {
$replacements['{'.$key.'}'] = '[object '.get_class($val).']';
} else {
$replacements['{'.$key.'}'] = '['.gettype($val).']';
return $replacements;