protected function logKeyValuePair($key, $value, $prefix = '')
{
if (in_array($key, $this->excludeKeys)) {
return '';
}
if (is_null($value) || is_scalar($value) || is_object($value) && method_exists($value, '__toString')) {
$copy_value = $value;
} elseif (is_object($value)) {
try {
$copy_value = '[object ' . serialize($value) . ']';
} catch (\Exception $e) {
return $e->getMessage() . PHP_EOL;
}
} else {
$copy_value = $value;
if (is_array($copy_value)) {
foreach ($copy_value as $key => &$val) {
if (in_array($key, $this->excludeKeys) && $prefix != '[header]') {
// XXX header にもマスクがかかってしまう
$val = '******';
}
}
}
try {
$copy_value = '[' . serialize($copy_value) . ']';
} catch (\Exception $e) {
return $e->getMessage() . PHP_EOL;
}
}
return ' ' . $prefix . ' ' . $key . '=' . $copy_value . PHP_EOL;
}