Skip to content

Commit

Permalink
Merge pull request #13 from hellowearemito/array-message-fix
Browse files Browse the repository at this point in the history
Fix logging of array messages.
  • Loading branch information
albertborsos authored Mar 27, 2017
2 parents 84578fc + aef716f commit 4cff174
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Target.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,16 @@ public function export()
$data['message'] = $context['msg'];
$extra = $context;
unset($extra['msg']);
$data['extra'] = VarDumper::export($extra);
$data['extra'] = $extra;
} else {
$data['message'] = is_array($context) ? VarDumper::export($context) : $context;
$data['extra'] = VarDumper::export($context);
// If the message is not a string, log it with VarDumper::export,
// like the other log targets in Yii.
$data['message'] = is_string($context) ? $context : VarDumper::export($context);
if (is_array($context)) {
// But if it's an array, also send it as an array,
// so that it can be displayed nicely in Sentry.
$data['extra'] = $context;
}
}

$this->sentry->capture($data, $traces);
Expand Down

0 comments on commit 4cff174

Please sign in to comment.