phptek / silverstripe-sentry

Flexible Sentry compatible bug aggregation client for Silverstripe applications.
BSD 3-Clause "New" or "Revised" License
11 stars 22 forks source link

Allow Silverstripe 5 #84

Closed elliot-sawyer closed 1 year ago

elliot-sawyer commented 1 year ago

I tried installing this on Silverstripe 5. Initially just added a || ^5 to composer.json, but there's some underlying fixes to the library that need to be made:

elliot-sawyer commented 1 year ago

The Silverstripe 4 version uses monolog/monolog: 1.27.1. The CMS5 version checks out monolog/monolog: 3.3.1

elliot-sawyer commented 1 year ago

Have not tested this in anger yet, but I managed to get it to report a basic message to Sentry. Add the following to any given _config.php file:

use Monolog\Level;
use Psr\Log\LoggerInterface;
use SilverStripe\Core\Injector\Injector;

$logger = Injector::inst()->get(LoggerInterface::class);
$logger->log(Level::Error, 'silverstripe 5 test');
BarryWype commented 1 year ago

Hi @elliot-sawyer, thanks for your PR. You reckon you can add:

/**
* @var mixed ClientBuilder|null
*/
private $client = null;

to SentryHandler.php to get rid of the deprecated notice? Cheers

phptek commented 1 year ago

Thanks @elliot-sawyer and @BarryWype I've manually applied both changes and the module builds, tests pass and I've tested both exception handling and manual logging as per @elliot-sawyer's example above.

See tag 5.0.

Thanks heaps.