itsgoingd / clockwork

Clockwork - php dev tools in your browser - server-side component
https://underground.works/clockwork
MIT License
5.69k stars 321 forks source link

Using MonologDataSource trigger error #676

Closed DominicDetta closed 8 months ago

DominicDetta commented 9 months ago

I'm using the monolog package version 2.9.2 and I obtain the following error:

PHP Fatal error:  Declaration of Clockwork\\Support\\Monolog\\Handler\\ClockworkHandler::write(array $record) must be compatible with Monolog\\Handler\\AbstractProcessingHandler::write(array $record): void in /var/www/html/vendor/itsgoingd/clockwork/Clockwork/Support/Monolog/Handler/ClockworkHandler.php on line 21

The code to add the new DataSource:

$this->clockwork->addDataSource(new \Clockwork\DataSource\MonologDataSource($this->logger));
DominicDetta commented 9 months ago

I found that the correct handler to use is Clockwork\Support\Monolog\Monolog2\ClockworkHandler. A new monolog datasource which implements this handler would be great. I can create a PR if you want.

itsgoingd commented 9 months ago

Ah, I guess I forgot we had a Monolog data source as well, when adding handlers for newer Monolog versions. I think we can improve the data source, to check what Monolog version is installed and register the correct handler.