Skip to content

Commit

Permalink
Merge pull request #165 from crf-devs/fix_log_circular
Browse files Browse the repository at this point in the history
Fix logs circular reference
  • Loading branch information
mRoca authored Mar 28, 2020
2 parents 0a2f68b + 8d48710 commit b538c36
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Monolog/Processor/ContextNormalizerProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ public function __invoke(array $record): array

foreach ($record['context'] as $key => $value) {
if ($this->normalizer->supportsNormalization($value, 'json')) {
$record['context'][$key] = $this->normalizer->normalize($value, 'json');
try {
$record['context'][$key] = $this->normalizer->normalize($value, 'json', [
'circular_reference_handler' => static function ($object) {
return (string) $object;
},
]);
} catch (\Throwable $e) {
$record['context'][$key] = $e->getMessage();
}
}
}

Expand Down

0 comments on commit b538c36

Please sign in to comment.