A small plugin to capture thrown exceptions (excluding status codes in the 400 range) to send to standard error stream
Icons by svgrepo.com & pngrepo.com
Exceptions thrown by craft will be handled automatically as this plugin listens to the Craft event ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION
.
This plugin would treat an exception thrown by Craft as CRITICAL
level which appears to best match for a generic purpose when handling ALL potential exceptions.
Monolog's description taken from RFC 5424 standard:
CRITICAL (500): Critical conditions. Example: Application component unavailable, unexpected exception.
For sending custom logs to the stream:
use madebyextreme\exceptionstostream\ExceptionsToStream;
public function bob()
{
ExceptionsToStream::getInstance()->log->debug('message');
ExceptionsToStream::getInstance()->log->info('message');
ExceptionsToStream::getInstance()->log->notice('message');
ExceptionsToStream::getInstance()->log->warning('message');
ExceptionsToStream::getInstance()->log->error('message');
ExceptionsToStream::getInstance()->log->critical('message');
ExceptionsToStream::getInstance()->log->alert('message');
ExceptionsToStream::getInstance()->log->emergency('message');
}
This plugin requires Craft CMS 3.0.0-beta.23 or later.
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project where your
composer.json
exists:cd /path/to/project
-
Updated
composer.json
:"repositories": [ { "type": "vcs", "url": "https://github.com/extreme-creations/craft-exceptionstostream.git" } ]
-
Then tell Composer to load the plugin:
composer require madebyextreme/exceptions-to-stream or docker-compose exec php bash -c "cd /var/www/site/craft/ && composer require madebyextreme/exceptions-to-stream"
-
In the Control Panel, go to Settings → Plugins and click the “Install” button for Exceptions To Stream, Or:
./craft plugin/install exceptions-to-stream or docker-compose exec php bash -c "cd /var/www/site/craft/ && ./craft plugin/install exceptions-to-stream"
Brought to you by Extreme