mirror of
https://github.com/Seldaek/monolog.git
synced 2025-02-24 06:52:34 +01:00
Inject rollbar handler.
Typecheck exceptions. Coding standard fix.
This commit is contained in:
parent
6734a4fbd1
commit
776a894487
@ -3,6 +3,7 @@
|
||||
namespace Monolog\Handler;
|
||||
|
||||
use RollbarNotifier;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Sends errors to Rollbar
|
||||
@ -19,26 +20,20 @@ class RollbarHandler extends AbstractProcessingHandler
|
||||
protected $rollbarNotifier;
|
||||
|
||||
/**
|
||||
* @param string $token post_server_item access token for the Rollbar project
|
||||
* @param string $environment This can be set to any string
|
||||
* @param string $root Directory your code is in; used for linking stack traces
|
||||
* @param integer $level The minimum logging level at which this handler will be triggered
|
||||
* @param boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
||||
* @param RollbarNotifier $rollbarNotifier RollbarNotifier object constructed with valid token
|
||||
* @param integer $level The minimum logging level at which this handler will be triggered
|
||||
* @param boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
||||
*/
|
||||
public function __construct($token, $environment = 'production', $root = null, $level = Logger::ERROR, $bubble = true)
|
||||
public function __construct(RollbarNotifier $rollbarNotifier, $level = Logger::ERROR, $bubble = true)
|
||||
{
|
||||
$this->rollbarNotifier = new RollbarNotifier(array(
|
||||
'access_token' => $token,
|
||||
'environment' => $environment,
|
||||
'root' => $root,
|
||||
));
|
||||
$this->rollbarNotifier = $rollbarNotifier;
|
||||
|
||||
parent::__construct($level, $bubble);
|
||||
}
|
||||
|
||||
protected function write(array $record)
|
||||
{
|
||||
if (isset($record['context']) and isset($record['context']['exception'])) {
|
||||
if (isset($record['context']['exception']) && $record['context']['exception'] instanceof Exception) {
|
||||
$this->rollbarNotifier->report_exception($record['context']['exception']);
|
||||
} else {
|
||||
$this->rollbarNotifier->report_message(
|
||||
|
Loading…
x
Reference in New Issue
Block a user