yii2-log icon indicating copy to clipboard operation
yii2-log copied to clipboard

TargetTrait don't parse Exception Message as @message when it parseText

Open Gectou4 opened this issue 8 years ago • 0 comments

If we want to gather Log information in some target (ie LogStash) we lost the message and it will not be exported.

Because on TargetTrait the parseText method will call get_object_vars() on $text when it's an instance of Exception. Unfortunately default Exception use protected attributes and we lost the default Exception message at this step.

We can do something like this :

case 'object':
                $vars = get_object_vars($text);
                if ($text instanceof \Exception) {
                    $vars['@message'] = $text->getMessage();
                }

                return $vars;

But I don't think it's the best manner to handle it.

Gectou4 avatar Mar 31 '17 13:03 Gectou4