Skip to content

TypeError on message of type array with SentryLogger #54

@vvoody-

Description

@vvoody-

public function log($message, string $priority = ILogger::INFO): void
{
if (!in_array($priority, $this->allowedPriority, true)) {
return;
}
$level = $this->getLevel($priority);
if ($level === null) {
return;
}
$scope = (new Scope())->setLevel(new Severity($level));
$this->makeRequest($message, $scope);
}
/**
* @param mixed $message
*/
protected function makeRequest($message, Scope $scope): void
{
$client = ClientBuilder::create($this->configuration[self::CONFIG_OPTIONS] + ['dsn' => $this->configuration[self::CONFIG_URL]])
->getClient();
SentrySdk::init()->bindClient($client);
if ($message instanceof Throwable) {
$client->captureException($message, $scope);
} else {
$client->captureMessage($message, null, $scope);
}
}

method log can accept message of type mixed. In my case it was array. But bit lower makeRequest is unable to process anything other than Throwable or string, since \Sentry\ClientInterface::captureMessage accepts only string message.

Where that array came from? https://github.com/nette/tracy/blob/024db76dc63e48afddddaa69792e453e54260707/src/Bridges/Psr/TracyToPsrLoggerAdapter.php#L50

Im not sure what would be fix here. Just reporting this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Triage: Now

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions